[英]cannot access class android.support.v4.app.FragmentActivity when i migrate to androidx
I have error "cannot access class android.support.v4.app.FragmentActivity " in 我在中出现错误“无法访问类android.support.v4.app.FragmentActivity”
GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build() GoogleApiClient.Builder(this).enableAutoManage(this,this).addApi(Auth.GOOGLE_SIGN_IN_API,gso).build()
I migarete to androidx and use library implementation('com.google.api-client:google-api-client-android:1.24.1') 我迁移到androidx并使用库实现('com.google.api-client:google-api-client-android:1.24.1')
I think GoogleApiClient require android.support.v4.app.FragmentActivity, but i have only androidx.appcompat.app.AppCompatActivity. 我认为GoogleApiClient需要android.support.v4.app.FragmentActivity,但我只有androidx.appcompat.app.AppCompatActivity。 Paths not match.
路径不匹配。 How to resolve this problem?
如何解决这个问题?
Step 1: 第1步:
Check if your dependencies migrated correctly to androidX, which you can do here - https://developer.android.com/jetpack/androidx/migrate . 检查您的依赖项是否已正确迁移到androidX,您可以在此处执行-https: //developer.android.com/jetpack/androidx/migrate 。 In your particular case - if you're using gradle go to your gradle.build file make sure
com.android.support:support-v4
is now androidx.legacy:legacy-support-v4:1.0.0
or higher. 在特定情况下-如果您使用gradle,请转到gradle.build文件,确保
com.android.support:support-v4
现在为androidx.legacy:legacy-support-v4:1.0.0
或更高版本。
Step 2: 第2步:
Clean IDE cache - if you're using Android Studio go to File -> Invalidate Caches / Restart 清理IDE缓存-如果您使用的是Android Studio,请转到“文件”->“使缓存无效/重新启动”
You need also update your dependencies of firebase library.
您还需要更新Firebase库的依赖项。
Because enableAutoManage() could useandroidx.fragment.app.FragmentActivity as parameter因为enableAutoManage()可以使用androidx.fragment.app.FragmentActivity作为参数
Step 0: I assume that you've migareted your project to androidx 第0步:假设您已将项目迁移到androidx
(If you haven't migareted your project to androidx, I strongly suggest you backup before you migarete it to anroidx. Because it is a large process) (如果您尚未将项目迁移到androidx,我强烈建议您在将项目迁移到anroidx之前先进行备份。因为这是一个很大的过程)
Step 1: backup your project (you probably will need to change some codes) 第1步:备份您的项目(您可能需要更改一些代码)
Step 2: go to your build.gradle(Module:app) file 步骤2:前往您的build.gradle(Module:app)文件
Step 3: update the version of your firebase dependencies 步骤3:更新Firebase依赖项的版本
(but be careful, some methods are deprecated in new version. So, maybe you will need change a lot of code) (但请注意,某些方法在新版本中已弃用。因此,也许您需要更改很多代码)
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.google.firebase:firebase-storage:18.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
I my solution this will be work. 我我的解决方案将是可行的。
https://stackoverflow.com/a/30627422/6709795 https://stackoverflow.com/a/30627422/6709795
For some of library, what use FragmentActivity, developers should updated their projects 对于某些使用FragmentActivity的库,开发人员应更新其项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.