当前位置:   article > 正文

No field mActive of type Landroid/util/SparseArray; in class Landroidx/fragment/app/FragmentManagerI_android nosuchfielderror: no instance field mactiv

android nosuchfielderror: no instance field mactive of type landroid/util/sp

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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
    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)
  • 1
  • 2
  • 3
  • 4

异常的意思就是说androlidx.fragment的版本发生冲突。

第一种解决办法

产生原因:

"androidx.appcompat:appcompat:${version["androidXSdkVersion"]}"
  • 1

因为引入了第三方的库

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"]}",
  • 1
  • 2
  • 3

所以,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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168

或者,在Terminal终端输入(需要配置ADB):

gradlew -q app:dependencies
  • 1

app是应用主工程。

如上即可查看依赖关系。

过程省略,研究的不够透彻…

最后刨掉androidXSdkVersion: “1.1.0” fragment 包,即可。

    //androidx
    api(rootProject.ext.dependencies["appcompat"]) {
        exclude module: 'annotation'
        exclude module: 'fragment'
    }
  • 1
  • 2
  • 3
  • 4
  • 5

另一种解决办法

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"]}",
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/275359
推荐阅读
相关标签
  

闽ICP备14008679号