【发布时间】:2018-03-12 11:34:54
【问题描述】:
我在 android 中运行 java 代码以使用 android 中的 oauth 2.0 制作凭据,当我运行此代码时遇到问题:
这是我的问题:
原因:java.lang.ClassNotFoundException:在路径上找不到类“java.awt.Desktop”:DexPathList[[zip file“/data/app/com.retrofitdemo-1/base.apk”], nativeLibraryDirectories=[/vendor/lib64, /system/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();
如何在android中导入awt包?
【问题讨论】:
-
我也有这个问题,你解决成功了吗?
标签: android