No field mActive of type Landroid/util/SparseArray; in class Landroidx/fragment/app/FragmentManagerI
2020-11-03 13:18:38.980 14299-14299/com.yoshin.test E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.yoshin.test, PID: 14299java.lang.NoSuchFieldError: No field mActive of type Landroid/util/Sparse
使用me.yokeyword.fragmentation出现异常
AS版本3.6.1
异常:
2020-11-03 13:18:38.980 14299-14299/com.yoshin.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.yoshin.test, PID: 14299
java.lang.NoSuchFieldError: No field mActive of type Landroid/util/SparseArray; in class Landroidx/fragment/app/FragmentManagerImpl; or its superclasses (declaration of 'androidx.fragment.app.FragmentManagerImpl' appears in /data/app/com.yoshin.test-1T4Ya-5hgPpyfCzKIYU4gQ==/base.apk!classes4.dex)
at androidx.fragment.app.FragmentationMagician.getActiveFragments(FragmentationMagician.java:156)
at me.yokeyword.fragmentation.SupportHelper.findStackFragment(SupportHelper.java:139)
at me.yokeyword.fragmentation.SupportHelper.findFragment(SupportHelper.java:114)
at com.yoshin.test.app.base.BaseSupportActivity.findFragment(BaseSupportActivity.java:187)
at com.yoshin.test.mvp.ui.activity.main.MainActivity.addFragment(MainActivity.java:110)
at com.yoshin.test.mvp.ui.activity.main.MainActivity.initBottomBar(MainActivity.java:79)
at com.yoshin.test.mvp.ui.activity.main.MainActivity.initData(MainActivity.java:75)
at com.jess.arms.base.BaseActivity.onCreate(BaseActivity.java:114)
at com.yoshin.test.app.base.BaseSupportActivity.onCreate(BaseSupportActivity.java:46)
at android.app.Activity.performCreate(Activity.java:7113)
at android.app.Activity.performCreate(Activity.java:7104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2846)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2971)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6738)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
java.lang.NoSuchFieldError: No field mActive of type Landroid/util/SparseArray;
in class Landroidx/fragment/app/FragmentManagerImpl;
or its superclasses (declaration of 'androidx.fragment.app.FragmentManagerImpl'
appears in /data/app/com.yoshin.test-1T4Ya-5hgPpyfCzKIYU4gQ==/base.apk!classes4.dex)
异常的意思就是说androlidx.fragment的版本发生冲突。
第一种解决办法
产生原因:
"androidx.appcompat:appcompat:${version["androidXSdkVersion"]}"
因为引入了第三方的库
fragmentationVersion : “1.3.8”
androidXSdkVersion: “1.1.0”
"fragmentation" : "me.yokeyword:fragmentation:${version["fragmentationVersion"]}",
"fragmentation-core" : "me.yokeyword:fragmentation-core:${version["fragmentationVersion"]}",
"fragmentation-swipeback" : "me.yokeyword:fragmentation-swipeback:${version["fragmentationVersion"]}",
所以,App与 me.yokeyword:fragmentation
内发生冲突导致。
百度从 https://blog.csdn.net/EthanCo/article/details/103704527 了解到可能是 “androidx.appcompat:appcompat:${version[“appcompatVersion”]}”
包的冲突。
究竟是不是如此,还需要进一步确认
确认哪个包下的依赖发生冲突
参考: https://blog.csdn.net/weixin_33752045/article/details/92382819
点击如上按钮,打印如下:
+--- androidx.multidex:multidex-instrumentation:2.0.0
| \--- androidx.multidex:multidex:2.0.0
+--- com.squareup.leakcanary:leakcanary-android:2.2
| +--- com.squareup.leakcanary:leakcanary-android-core:2.2
| | +--- com.squareup.leakcanary:shark-android:2.2
| | | +--- com.squareup.leakcanary:shark:2.2
| | | | +--- com.squareup.leakcanary:shark-graph:2.2
| | | | | +--- com.squareup.leakcanary:shark-hprof:2.2
| | | | | | +--- com.squareup.leakcanary:shark-log:2.2
| | | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50
| | | | | | | \--- org.jetbrains:annotations:13.0 -> 16.0.1
| | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | | | | \--- com.squareup.okio:okio:2.2.2
| | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.60 -> 1.3.50 (*)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | | | \--- com.squareup.okio:okio:2.2.2 (*)
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | +--- com.squareup.leakcanary:leakcanary-object-watcher-android:2.2
| | | +--- com.squareup.leakcanary:leakcanary-object-watcher:2.2
| | | | +--- com.squareup.leakcanary:shark-log:2.2 (*)
| | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | +--- com.squareup.leakcanary:leakcanary-object-watcher-android-androidx:2.2
| | | +--- com.squareup.leakcanary:leakcanary-object-watcher-android:2.2 (*)
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | +--- com.squareup.leakcanary:leakcanary-object-watcher-android-support-fragments:2.2
| | | +--- com.squareup.leakcanary:leakcanary-object-watcher-android:2.2 (*)
| | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 (*)
+--- com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-20
+--- org.projectlombok:lombok:1.16.18
+--- com.tencent:mmkv-static:1.2.4
| \--- androidx.annotation:annotation:1.1.0
+--- me.yokeyword:fragmentation:1.3.8
| \--- me.yokeyword:fragmentation-core:1.3.8
+--- me.yokeyword:fragmentation-core:1.3.8
+--- androidx.cardview:cardview:1.0.0
| \--- androidx.annotation:annotation:1.0.0 -> 1.1.0
+--- org.simple:androideventbus:1.0.5.1
+--- me.jessyan:progressmanager:1.5.0
+--- me.jessyan:retrofit-url-manager:1.4.0
+--- me.jessyan:lifecyclemodel:1.0.1
+--- com.github.markomilos:paginate:0.5.1
+--- project :arms
| +--- androidx.legacy:legacy-support-v4:1.0.0
| | +--- androidx.core:core:1.0.0 -> 1.1.0
| | | +--- androidx.lifecycle:lifecycle-runtime:2.0.0
| | | | +--- androidx.lifecycle:lifecycle-common:2.0.0
| | | | \--- androidx.arch.core:core-common:2.0.0
| | | +--- androidx.versionedparcelable:versionedparcelable:1.1.0
| | | | \--- androidx.collection:collection:1.0.0 -> 1.1.0-alpha01
| | | \--- androidx.collection:collection:1.0.0 -> 1.1.0-alpha01
| | +--- androidx.media:media:1.0.0
| | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | \--- androidx.versionedparcelable:versionedparcelable:1.0.0 -> 1.1.0 (*)
| | +--- androidx.legacy:legacy-support-core-utils:1.0.0
| | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | +--- androidx.documentfile:documentfile:1.0.0
| | | +--- androidx.loader:loader:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | +--- androidx.lifecycle:lifecycle-livedata:2.0.0
| | | | | +--- androidx.arch.core:core-runtime:2.0.0
| | | | | | \--- androidx.arch.core:core-common:2.0.0
| | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0
| | | | | | +--- androidx.lifecycle:lifecycle-common:2.0.0
| | | | | | +--- androidx.arch.core:core-common:2.0.0
| | | | | | \--- androidx.arch.core:core-runtime:2.0.0 (*)
| | | | | \--- androidx.arch.core:core-common:2.0.0
| | | | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
| | | +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
| | | \--- androidx.print:print:1.0.0
| | +--- androidx.legacy:legacy-support-core-ui:1.0.0
| | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
| | | +--- androidx.customview:customview:1.0.0
| | | | \--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | +--- androidx.viewpager:viewpager:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | \--- androidx.customview:customview:1.0.0 (*)
| | | +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | \--- androidx.customview:customview:1.0.0 (*)
| | | +--- androidx.drawerlayout:drawerlayout:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | \--- androidx.customview:customview:1.0.0 (*)
| | | +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | \--- androidx.customview:customview:1.0.0 (*)
| | | +--- androidx.interpolator:interpolator:1.0.0
| | | +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
| | | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | | \--- androidx.interpolator:interpolator:1.0.0
| | | +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
| | | | \--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | \--- androidx.cursoradapter:cursoradapter:1.0.0
| | \--- androidx.fragment:fragment:1.0.0 -> 1.1.0-alpha02
| | +--- androidx.core:core:1.1.0-alpha01 -> 1.1.0 (*)
| | +--- androidx.viewpager:viewpager:1.0.0 (*)
| | +--- androidx.loader:loader:1.0.0 (*)
| | +--- androidx.activity:activity:1.0.0-alpha02
| | | +--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 (*)
| | | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
| | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
| +--- androidx.appcompat:appcompat:1.1.0-alpha01
| | +--- androidx.core:core:1.1.0-alpha01 -> 1.1.0 (*)
| | +--- androidx.collection:collection:1.1.0-alpha01
| | +--- androidx.cursoradapter:cursoradapter:1.0.0
| | +--- androidx.fragment:fragment:1.1.0-alpha02 (*)
| | +--- androidx.vectordrawable:vectordrawable:1.0.1
| | | \--- androidx.core:core:1.0.0 -> 1.1.0 (*)
| | +--- androidx.vectordrawable:vectordrawable-animated:1.0.0
| | | +--- androidx.vectordrawable:vectordrawable:1.0.0 -> 1.0.1 (*)
| | | \--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)
| | \--- androidx.drawerlayout:drawerlayout:1.0.0 (*)
| +--- androidx.recyclerview:recyclerview:1.1.0
| | +--- androidx.core:core:1.1.0 (*)
| | +--- androidx.customview:customview:1.0.0 (*)
| | \--- androidx.collection:collection:1.0.0 -> 1.1.0-alpha01
| +--- androidx.annotation:annotation:1.1.0
| +--- com.jakewharton:butterknife:10.2.1
| | \--- com.jakewharton:butterknife-runtime:10.2.1
| | \--- com.jakewharton:butterknife-annotations:10.2.1
| +--- io.reactivex.rxjava2:rxjava:2.2.18
| | \--- org.reactivestreams:reactive-streams:1.0.3
| +--- io.reactivex.rxjava2:rxandroid:2.1.1
| +--- com.github.VictorAlbertos.RxCache:runtime:1.8.3-2.x
| | \--- com.github.VictorAlbertos.RxCache:core:1.8.3-2.x
| | \--- org.glassfish:javax.annotation:10.0-b28
| +--- com.trello.rxlifecycle2:rxlifecycle:2.2.2
| +--- com.trello.rxlifecycle2:rxlifecycle-android:2.2.2
| +--- com.github.tbruyelle:rxpermissions:0.10.2
| | \--- androidx.fragment:fragment:1.0.0-rc01 -> 1.1.0-alpha02 (*)
| +--- me.jessyan:rxerrorhandler:2.1.1
| +--- com.squareup.retrofit2:retrofit:2.7.2
| +--- com.squareup.okhttp3:okhttp:3.12.9
| | \--- com.squareup.okio:okio:1.15.0 -> 2.2.2 (*)
| +--- com.google.dagger:dagger:2.26
| | \--- javax.inject:javax.inject:1
| +--- com.google.code.gson:gson:2.8.0
| \--- com.jakewharton.timber:timber:4.7.1
| \--- org.jetbrains:annotations:16.0.1
+--- me.jessyan:autosize:1.2.1
+--- com.android.support.constraint:constraint-layout:1.1.3 -> androidx.constraintlayout:constraintlayout:1.1.2
| \--- androidx.constraintlayout:constraintlayout-solver:1.1.2
+--- project :arms-imageloader-glide
| \--- com.github.bumptech.glide:glide:4.11.0
| +--- com.github.bumptech.glide:gifdecoder:4.11.0
| +--- com.github.bumptech.glide:disklrucache:4.11.0
| +--- com.github.bumptech.glide:annotations:4.11.0
| \--- androidx.exifinterface:exifinterface:1.0.0
\--- com.aliyun.ams:alicloud-android-push:3.2.0
+--- com.aliyun.ams:alicloud-android-agoo:1.0.0
| \--- com.taobao.android:accs_sdk_taobao:3.3.7.6-emas
| \--- com.taobao.android:tlog_adapter:1.1.0.2
+--- com.taobao.android:accs_sdk_taobao:3.3.7.6-emas (*)
+--- com.taobao.android:networksdk:3.5.5.2-open
+--- com.taobao.android:tnet4android:3.1.14.7-all
+--- com.aliyun.ams:alicloud-android-utils:1.1.6.4
| \--- com.aliyun.ams:alicloud-android-ut:5.4.3
| \--- com.aliyun.ams:alicloud-android-utdid:1.1.5.3 -> 2.5.1-proguard
+--- com.aliyun.ams:alicloud-android-beacon:1.0.4.3
| \--- com.aliyun.ams:alicloud-android-utdid:1.1.5.4 -> 2.5.1-proguard
\--- com.aliyun.ams:alicloud-android-utdid:2.5.1-proguard
或者,在Terminal终端输入(需要配置ADB):
gradlew -q app:dependencies
app是应用主工程。
如上即可查看依赖关系。
过程省略,研究的不够透彻…
最后刨掉androidXSdkVersion: “1.1.0”
中fragment
包,即可。
//androidx
api(rootProject.ext.dependencies["appcompat"]) {
exclude module: 'annotation'
exclude module: 'fragment'
}
另一种解决办法
https://blog.csdn.net/EthanCo/article/details/103704527
fragmentationVersion : “1.0.2”
// "fragmentation" : "me.yokeyword:fragmentation:${version["fragmentationVersion"]}",
// "fragmentation-core" : "me.yokeyword:fragmentation-core:${version["fragmentationVersion"]}",
// "fragmentation-swipeback" : "me.yokeyword:fragmentation-swipeback:${version["fragmentationVersion"]}",
"fragmentation" : "me.yokeyword:fragmentationx:${version["fragmentationVersion"]}",
"fragmentation-core" : "me.yokeyword:fragmentationx-core:${version["fragmentationVersion"]}",
"fragmentation-swipeback" : "me.yokeyword:fragmentationx-swipeback:${version["fragmentationVersion"]}",
更多推荐
所有评论(0)