After the migration to AndroidX i'am facing this the following issue with the Google Auth lib:
On Android 9 API 28:
java.lang.IncompatibleClassChangeError: Class 'com.google.android.gms.auth.api.signin.internal.SignInHubActivity' does not implement interface 'androidx.lifecycle.LifecycleOwner' in call to 'androidx.lifecycle.Lifecycle androidx.lifecycle.LifecycleOwner.getLifecycle()' (declaration of 'androidx.lifecycle.LiveData' appears in /data/app/fourbottles.bsg.workinghours4b-G1onPKgFFE-l3aqjx0qDJw==/split_lib_dependencies_apk.apk)
at androidx.lifecycle.LiveData.observe(LiveData.java:172)
at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setCallback(LoaderManagerImpl.java:100)
at androidx.loader.app.LoaderManagerImpl.createAndInstallLoader(LoaderManagerImpl.java:400)
at androidx.loader.app.LoaderManagerImpl.initLoader(LoaderManagerImpl.java:421)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.zzn(Unknown Source:80)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.onActivityResult(Unknown Source:68)
at android.app.Activity.dispatchActivityResult(Activity.java:7454)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4353)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
On Android 5.0.2 API 22
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.lifecycle.Lifecycle$State androidx.lifecycle.Lifecycle.getCurrentState()' on a null object reference
at androidx.lifecycle.LiveData.observe(LiveData.java:172)
at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setCallback(LoaderManagerImpl.java:100)
at androidx.loader.app.LoaderManagerImpl.createAndInstallLoader(LoaderManagerImpl.java:400)
at androidx.loader.app.LoaderManagerImpl.initLoader(LoaderManagerImpl.java:421)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.zzn(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.SignInHubActivity.onActivityResult(Unknown Source)
at android.app.Activity.dispatchActivityResult(Activity.java:6139)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3535)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3582)
at android.app.ActivityThread.access$1300(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I'am using the following lib versions:
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.multidex:multidex:2.0.1'
The code is crashing as soon as i start an activity with the intent:
val signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient)
startActivityForResult(signInIntent, LOGIN_WITH_GOOGLE_CODE)
I have the following properties into the settings.gradle file:
android.useAndroidX=true
android.enableJetifier=true
The Google Auth lib doesn't support authentication with AndroidX libs?
Is there a way to start an intent from an androidX lib with the supported lib behaviour?
I accept answers in both java and kotlin languages.
Update 1: 27.12.2017
Google api client creation:
GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
googleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
.build();
It may be beacuse of enableAutoManage
?
I managed to login with the following piece of code:
Task<GoogleSignInAccount> sign = googleSignInClient.silentSignIn();
GoogleSignInAccount result = sign.getResult();
So i think there is no problem with the credentials or the other configuration files. In this way the user won't be able to choose an account.
I think that Jetifier is failing in same way.
With API 27 i'am getting the same error.
the same issue! I've just added the "core" dependency and bumped "appcompat" to the latest alpha version and it helped.
dependencies {
implementation "androidx.core:core:1.1.0-alpha03"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.annotation:annotation:1.0.1"
implementation "androidx.recyclerview:recyclerview:1.1.0-alpha01"
implementation "androidx.appcompat:appcompat:1.1.0-alpha01"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.cardview:cardview:1.0.0"
implementation "com.google.android.material:material:1.1.0-alpha02"
implementation "com.google.firebase:firebase-core:16.0.6"
implementation "com.google.firebase:firebase-auth:16.1.0"
implementation "com.google.firebase:firebase-storage:16.0.5"
implementation "com.google.firebase:firebase-perf:16.2.3"
implementation 'com.firebaseui:firebase-ui-database:4.3.0'
implementation "com.google.android.gms:play-services-auth:16.0.1"
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation "com.google.android.gms:play-services-maps:16.0.0"
...
}
I use:
compileSdkVersion 28
buildToolsVersion "28.0.3"
Top gradle.build:
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
...
}
gradle.properties:
android.debug.obsoleteApi=true
android.enableR8 = true
android.useAndroidX=true
android.enableJetifier=true
gradle wrapper's gradle version is set to gradle-4.10.1-all.zip. Also I tried to Invalidate/restart my AS 3.3. Hope it will help somebody.