我正在 android 中运行 java 代码,以便在 android 中使用 oauth 2.0 制作凭证,当我运行此代码时,我遇到问题:
这是我的问题:
原因:java.lang.ClassNotFoundException:在路径上找不到类“java.awt.Desktop”:DexPathList[[zip 文件“/data/app/com.retrofitdemo-1/base.apk”],nativeLibraryDirectories=[ /供应商/lib64,/系统/lib64]]
这是我的代码:
private static final GoogleClientSecrets googleSecrets = new GoogleClientSecrets();
googleSecrets.setInstalled(
new GoogleClientSecrets.Details()
.setClientId("542678605378-hlspiumlr34nq04cmjtkft17i6k3hvr0.apps.googleusercontent.com")
.setClientSecret("{client_secretid}")
);
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
AndroidHttp.newCompatibleTransport(), JacksonFactory.getDefaultInstance(), googleSecrets, Arrays.asList(SCOPES))
.setAccessType("offline")
.build();
Credential credential1 = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
Log.i("AA","credential1--"+credential1);
new MakeRequestTask(credential).execute();
Run Code Online (Sandbox Code Playgroud)
如何在android中导入awt包?
请帮助我,如何在android中导入awt包
你不能。据推测,您正在使用一些专为桌面 Java 而不是 Android 使用而设计的库。找到一些专为 Android 使用而设计的替换库。
| 归档时间: |
|
| 查看次数: |
1682 次 |
| 最近记录: |