Android 具有 Google 驱动器 API 的应用程序在选择帐户后卡住了。为什么?
Android App with Google Drive API stucks after choosing an account. Why?
我正在尝试了解如何将 Google Drive API 集成到我的 Android 应用程序中(使用 Android Studio)。我已经尝试了我在此处找到的示例应用程序 (https://github.com/googleworkspace/android-samples/tree/master/drive/deprecation),但是在 Google API 控制台配置之后,当我选择一个帐户时,我的应用程序陷入无限循环。为什么?问题出在哪里?
我也试过这个(https://youtu.be/5bSEIQYJzKs)教程,但我遇到了同样的问题。
这是我的 build.gradle 具体行:
implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation ('com.google.apis:google-api-services-drive:v3-rev136-1.25.0')
{
exclude group: 'org.apache.httpcomponents'
}
implementation ('com.google.api-client:google-api-client-android:1.26.0')
{
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
这是我使用的版本
compileSdkVersion 30
buildToolsVersion "30.0.3"
问题出在这行代码中,并且仅当我使用“.requestScopes(new Scope(DriveScopes.DRIVE_FILE))”时才会发生:
如果我不使用 .requestScopes(new Scope(DriveScopes.DRIVE_FILE))",那么代码工作正常。用户确实登录
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(DriveScopes.DRIVE_FILE))
.requestEmail()
.build();
GoogleSignInClient client= GoogleSignIn.getClient(this,signInOptions);
Intent i= client.getSignInIntent();
startActivityForResult(i,400);
(似乎 activity 从来没有 returns 任何值)。
没有“.requestScopes(new Scope(DriveScopes.DRIVE_FILE))”,授权请求成功。
这是我的 Google 控制台配置:
The client ID
(抱歉,它可能会显示为 link,但 Whosebug 告诉我无法放置 img)
和
“.../auth/drive.file”是我在 google Consent window 中向用户显示的请求的授权。
我不知道说出来是否重要,但我使用真实的 phone 而不是 Android Studio 模拟器来测试我的应用程序。
我刚刚解决了。对于所有遇到此问题的人:从 Google API 控制台,从测试状态中删除同意屏幕并发布它。
查看 https://issuetracker.google.com/issues/178183308 向 Google 报告问题的地方。
我正在尝试了解如何将 Google Drive API 集成到我的 Android 应用程序中(使用 Android Studio)。我已经尝试了我在此处找到的示例应用程序 (https://github.com/googleworkspace/android-samples/tree/master/drive/deprecation),但是在 Google API 控制台配置之后,当我选择一个帐户时,我的应用程序陷入无限循环。为什么?问题出在哪里? 我也试过这个(https://youtu.be/5bSEIQYJzKs)教程,但我遇到了同样的问题。 这是我的 build.gradle 具体行:
implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation ('com.google.apis:google-api-services-drive:v3-rev136-1.25.0')
{
exclude group: 'org.apache.httpcomponents'
}
implementation ('com.google.api-client:google-api-client-android:1.26.0')
{
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
这是我使用的版本
compileSdkVersion 30
buildToolsVersion "30.0.3"
问题出在这行代码中,并且仅当我使用“.requestScopes(new Scope(DriveScopes.DRIVE_FILE))”时才会发生: 如果我不使用 .requestScopes(new Scope(DriveScopes.DRIVE_FILE))",那么代码工作正常。用户确实登录
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(DriveScopes.DRIVE_FILE))
.requestEmail()
.build();
GoogleSignInClient client= GoogleSignIn.getClient(this,signInOptions);
Intent i= client.getSignInIntent();
startActivityForResult(i,400);
(似乎 activity 从来没有 returns 任何值)。 没有“.requestScopes(new Scope(DriveScopes.DRIVE_FILE))”,授权请求成功。 这是我的 Google 控制台配置: The client ID (抱歉,它可能会显示为 link,但 Whosebug 告诉我无法放置 img) 和 “.../auth/drive.file”是我在 google Consent window 中向用户显示的请求的授权。 我不知道说出来是否重要,但我使用真实的 phone 而不是 Android Studio 模拟器来测试我的应用程序。
我刚刚解决了。对于所有遇到此问题的人:从 Google API 控制台,从测试状态中删除同意屏幕并发布它。
查看 https://issuetracker.google.com/issues/178183308 向 Google 报告问题的地方。