首页 文章

引起:java.lang.ClassNotFoundException:在Android中没有找到类“java.awt.Desktop”

提问于
浏览
1

我在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包?

1 回答

  • 0

    请帮助我,如何在android中导入awt包

    你不能 . 据推测,您使用的是一些专为桌面Java而非Android设计的库 . 找一些专为Android设计的替换库 .

相关问题