From 588c0637310623d86c55d06f0adc72972b0bac22 Mon Sep 17 00:00:00 2001 From: Clayton Wilkinson Date: Wed, 19 Sep 2018 09:58:19 -0700 Subject: [PATCH] Updating for 1.0.4 * bumped tooling versions to latest * handled cancelled and other onActivityResult() return codes that cause NPE. * Depend on latest Play Services Auth library. Change-Id: Ib783e6943800d86d5a13aafd6dc86bdea601b0ab --- .../Editor/GoogleSignInDependencies.xml | 2 +- build.gradle | 6 ++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- native-googlesignin/build.gradle | 5 ++--- .../google/googlesignin/GoogleSignInFragment.java | 15 +++++++++++---- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml index 19c1887..625d2e5 100644 --- a/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml +++ b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml @@ -3,7 +3,7 @@ - + extra-google-m2repository diff --git a/build.gradle b/build.gradle index af5716f..50f8d7e 100644 --- a/build.gradle +++ b/build.gradle @@ -19,10 +19,11 @@ import groovy.io.FileType buildscript { repositories { + google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -31,6 +32,7 @@ buildscript { allprojects { repositories { + google() jcenter() } } @@ -66,7 +68,7 @@ project.ext { git_exe = 'git' } - pluginVersion = "1.0.3" + pluginVersion = "1.0.4" currentPluginBasename = 'google-signin-plugin' currentPluginName = (currentPluginBasename + '-' + pluginVersion + '.unitypackage') diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f027d86..24eb41f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/native-googlesignin/build.gradle b/native-googlesignin/build.gradle index e3d4d76..ba2f0d9 100644 --- a/native-googlesignin/build.gradle +++ b/native-googlesignin/build.gradle @@ -33,7 +33,6 @@ project.ext.baseName = "google-signin-support" android { compileSdkVersion 26 - buildToolsVersion "26.0.3" defaultConfig { minSdkVersion 14 targetSdkVersion 26 @@ -45,7 +44,7 @@ android { } } ndk { - abiFilters 'x86', 'armeabi-v7a' + abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' } } lintOptions { @@ -113,5 +112,5 @@ uploadArchives { } dependencies { - compile "com.google.android.gms:play-services-auth:10.2.6" + api "com.google.android.gms:play-services-auth:16.0.0" } diff --git a/native-googlesignin/src/main/java/com/google/googlesignin/GoogleSignInFragment.java b/native-googlesignin/src/main/java/com/google/googlesignin/GoogleSignInFragment.java index 5b10455..e844c03 100644 --- a/native-googlesignin/src/main/java/com/google/googlesignin/GoogleSignInFragment.java +++ b/native-googlesignin/src/main/java/com/google/googlesignin/GoogleSignInFragment.java @@ -412,7 +412,7 @@ private void buildClient(TokenRequest request) { } } if (request.getHidePopups()) { - View invisible = new View(getContext()); + View invisible = new View(getActivity()); invisible.setVisibility(View.INVISIBLE); invisible.setClickable(false); clientBuilder.setViewForPopups(invisible); @@ -456,7 +456,7 @@ private GoogleSignInOptionsExtension getGamesExtension() { setter.invoke(builder, false); Method buildMethod = builder.getClass().getMethod("build"); - return (GoogleSignInOptionsExtension) builderMethod.invoke(builder); + return (GoogleSignInOptionsExtension) buildMethod.invoke(builder); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( @@ -526,8 +526,15 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); TokenRequest request = this.request; if (request != null) { - GoogleSignInAccount acct = result.getSignInAccount(); - request.setResult(result.getStatus().getStatusCode(), acct); + if (result == null) { + // This usually indicates a problem with Google Play Services not working correctly. + int returnCode = resultCode >= 0 ? CommonStatusCodes.ERROR : resultCode; + request.setResult( returnCode, null); + GoogleSignInHelper.logError("GoogleSignIn result is null, returning error."); + } else { + GoogleSignInAccount acct = result.getSignInAccount(); + request.setResult(result.getStatus().getStatusCode(), acct); + } } else { GoogleSignInHelper.logError("Pending request is null, can't " + "return result!"); }