Skip to content Skip to sidebar Skip to footer

Google Auth Migrating To Androidx: Signinhubactivity Does Not Implement Lifecycle

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.androi

Solution 1:

I fixed this issue by using the latest version of the appcompat library:

implementation "androidx.appcompat:appcompat:1.1.0-rc01"

In previous versions the class AppCompatActivity did not implement the LifecycleOwner interface thus leading to the errors you observed.

Solution 2:

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=trueandroid.enableR8 = trueandroid.useAndroidX=trueandroid.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.

Solution 3:

I found an work around until i find a fix or the library is updated:

Task<GoogleSignInAccount> sign = googleSignInClient.silentSignIn();

if(sign.isSuccessful())
{
    GoogleSignInAccountresultAccount= sign.getResult();
    handleGoogleLogin(resultAccount);
}else
{
     IntentsignInIntent= googleSignInClient.getSignInIntent();
     startActivityForResult(signInIntent, GOOGLE_SIGN_IN_CODE);
}

The code try to sign in silently, if the user didn't allow the sign in already, will start the intent. In my case the intent let me choose the account and crashes after tapping on the account. After the first tap, the silent signin will work.

Solution 4:

Latest update: android.core:1.2.0-alpha02 still does not have that method in ComponentActivity.getLifeCycle()

I update to latest version of android.core:

dependencies {
    // ...
    def core_version = "1.2.0-alpha04"
    implementation "androidx.core:core:$core_version"
    implementation "androidx.core:core-ktx:$core_version"
}

The latest version can be found in https://developer.android.com/jetpack/androidx/releases/core

Solution 5:

I fixed the issue by adding this dependency to my gradle:

implementation 'androidx.arch.core:core-runtime:2.0.1-alpha01'

EDIT

Those are the versions i have used:

  • App level gradle compileSdkVersion = 28, buildToolsVersion = "28.0.3":

    implementation "com.google.android.gms:play-services-auth:16.0.1"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    implementation 'androidx.arch.core:core-runtime:2.0.1-alpha01'

    All com.android.support libraries are of version: 28.0.0

  • Project level gradle:

    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath 'com.google.gms:google-services:4.2.0'

Note 1: If you have the below line, try to build without it:

implementation "androidx.legacy:legacy-support-v4:1.0.0"

Note 2: If you are building with Android Studio 3.3 (the latest at the time i am writing this answer) I got these errors when trying to migrate to androidX:

WARNING: API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance. To determine what is calling variant.getJavaCompiler(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Affected Modules: app

I could not manage to fix it, but just running the project with this error exists works surprisingly.

Post a Comment for "Google Auth Migrating To Androidx: Signinhubactivity Does Not Implement Lifecycle"