Google API: java.lang.ClassNotFoundException: 没找到 class "sun.misc.Service"

Google API: java.lang.ClassNotFoundException: Didn't find class "sun.misc.Service"

我已经导入了所有必要的 google 依赖项来验证用户:

def play_services_version = "15.0.1"
implementation 'com.google.api-client:google-api-client:1.33.0'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.32.1'
implementation 'com.google.apis:google-api-services-drive:v3-rev20211107-1.32.1'
implementation 'com.sun.net.httpserver:http:20070405'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation "com.google.android.gms:play-services-auth:$play_services_version"
implementation "com.google.android.gms:play-services-drive:$play_services_version"
implementation 'com.squareup.okio:okio:1.14.0'

正在接收用户凭据。

/**
 * Creates an authorized Credential object.
 * @param HTTP_TRANSPORT The network HTTP Transport.
 * @return An authorized Credential object.
 * @throws IOException If the credentials.json file cannot be found.
 */
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
    // Load client secrets.
    InputStream in = DriveQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
    if (in == null) {
        throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
    }
    GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));


    //Token Folder
    java.io.File s = new File(TOKENS_DIRECTORY_PATH);
    if(!s.exists()){
        boolean mkdir = s.mkdir();
    }
    File tokenFolder = new File(con.getFilesDir() +
            File.separator + TOKENS_DIRECTORY_PATH);
    if (!tokenFolder.exists()) {
        tokenFolder.mkdirs();
    }

    // Build flow and trigger user authorization request.
    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
            .setDataStoreFactory(new FileDataStoreFactory(tokenFolder))
            .setAccessType("offline")
            .build();

    LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();

    Credential credential = new AuthorizationCodeInstalledApp(flow,receiver ).authorize("user");
    //returns an authorized Credential object.
    return credential;
}

因为那是 official google 文档,代码应该是最新版本,但是执行代码时,我收到 Failed resolution of: Lsun/misc/Service Caused by: java.lang.ClassNotFoundException: Didn't find class "sun.misc.Service" 错误。

这是由于缺少依赖项还是来自 google 的错误?

the documentation that you linked to 的第一句话是:“完成本页其余部分描述的步骤,创建一个简单的 Java command-line 应用程序,向 Drive API。” (强调)这些说明不适用于 Android。