迁移到AndroidX后,Google登录无法正常工作

我在我的
Android应用程序中集成了Google Sign.当我使用spp compact v28库时,它工作得很好,但是在将我的应用程序集成到androidx之后失败了以下异常.

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/com.grecloud-2/split_lib_dependencies_apk.apk:classes89.dex)
        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:6500)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3936)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3983)
        at android.app.ActivityThread.-wrap16(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5765)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

具有Google登录代码的活动扩展了AppCompatActivity并实现了GoogleApiClient.OnConnectionFailedListener,View.OnClickListener

最佳答案 在build.gradle中删除以下两行后,它对我有用:

implementation "androidx.media:media:1.1.0-alpha01"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
点赞