公式サンプルアプリからコードをコピーしたにもかかわらず、アプリがPlayストアからリリースされると、認証同意画面が表示されません。 Google Apiデベロッパーコンソールで、公開用(私用のキーストアを使用)とデバッグ用(Androidスタジオのデバッグキーストアを使用)の2つのOAuth 2.0資格情報を正しく生成しました。Playサービス11.6:公開時にOAuth同意画面が表示されない
アップデート:デバッグモードの古い4.4エミュレータに私のアプリケーションをインストールしました新しいデバイスのリリースアプリケーションと同じ動作に気付きました。同意画面は表示されず、Logcatに次のメッセージが表示されます:
W/GooglePlayServicesUtil:Google Playサービスが古くなりました。 11717000が必要ですが、11509030
を発見し、それは、新しいGoogleApiインタフェースは/更新PlayServicesをインストールするようにユーザーに促すために失敗したということでした公式ドキュメントはそれを言っても?
build.gradle(アプリ)
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.android.gms:play-services-drive:11.6.0'
のAndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
:ここ
は私のコードです
DriveActivity.java
private static final int REQUEST_CODE_SIGN_IN = 0;
protected GoogleSignInClient mGoogleSignInClient;
protected DriveClient mDriveClient;
protected DriveResourceClient mDriveResourceClient;
protected abstract void onDriveConnected();
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_SIGN_IN:
if (resultCode == RESULT_OK) {
Task<GoogleSignInAccount> getAccountTask = GoogleSignIn.getSignedInAccountFromIntent(data);
if (getAccountTask.isSuccessful()) {
initializeDriveClient(getAccountTask.getResult());
}
else {
Toast.makeText(this, "Sign-in failed.", Toast.LENGTH_LONG).show();
}
}
break;
}
}
protected void signIn() {
GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(this);
if (signInAccount != null && signInAccount.getGrantedScopes().contains(Drive.SCOPE_FILE)) {
initializeDriveClient(signInAccount);
}
else {
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Drive.SCOPE_FILE)
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, signInOptions);
startActivityForResult(mGoogleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);
}
}
private void initializeDriveClient(GoogleSignInAccount signInAccount) {
mDriveClient = Drive.getDriveClient(this, signInAccount);
mDriveResourceClient = Drive.getDriveResourceClient(this, signInAccount);
onDriveConnected();
}
GoogleSignIn.getClient()にアクティビティを渡すと、Google Playサービスの更新を促すダイアログが表示されます。物理的なデバイスで試してみませんか? Playストアのないエミュレータの場合、動作は若干異なります(つまり、ログに表示されるエラーのみ)。 –
残念なことに物理デバイスでもダイアログが表示されません... – Alessandro
うーん...これは期待していません。 Google PlayサービスがSDKより古い場合、getClient(Activity、options)はダイアログを表示します。 DriveActivity.javaに貼り付けたものはアクティビティコードからの直接コピーですか?あなたの物理的なデバイスは11.6よりも古いPlayサービスを持っていますか? –