我的生产版本上的JellyBean(4.2.2)设备出现了奇怪的问题/异常NoSuchMethodException。附上了堆栈跟踪的截图。
这是我的Gson版本:
implementation 'com.google.code.gson:gson:2.8.4'
我每次尝试拨打gson.fromJson
或gson.toJson
时都会收到此错误。
这是我的依赖树:
+--- project :Scratch
| \--- com.android.support:appcompat-v7:23.4.0 -> 27.1.1
| +--- com.android.support:support-annotations:27.1.1
| +--- com.android.support:support-core-utils:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | \--- com.android.support:support-compat:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | \--- android.arch.lifecycle:runtime:1.1.0 -> 1.1.1
| | +--- android.arch.lifecycle:common:1.1.1
| | | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| | +--- android.arch.core:common:1.1.1
| | | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| +--- com.android.support:support-fragment:27.1.1
| | +--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-core-ui:27.1.1
| | | +--- com.android.support:support-annotations:27.1.1
| | | +--- com.android.support:support-compat:27.1.1 (*)
| | | \--- com.android.support:support-core-utils:27.1.1 (*)
| | +--- com.android.support:support-core-utils:27.1.1 (*)
| | +--- com.android.support:support-annotations:27.1.1
| | +--- android.arch.lifecycle:livedata-core:1.1.0 -> 1.1.1
| | | +--- android.arch.lifecycle:common:1.1.1 (*)
| | | +--- android.arch.core:common:1.1.1 (*)
| | | \--- android.arch.core:runtime:1.1.1
| | | +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| | | \--- android.arch.core:common:1.1.1 (*)
| | \--- android.arch.lifecycle:viewmodel:1.1.0 -> 1.1.1
| | \--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| +--- com.android.support:support-vector-drawable:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | \--- com.android.support:support-compat:27.1.1 (*)
| \--- com.android.support:animated-vector-drawable:27.1.1
| +--- com.android.support:support-vector-drawable:27.1.1 (*)
| \--- com.android.support:support-core-ui:27.1.1 (*)
+--- com.squareup.okhttp3:logging-interceptor:3.9.0
| \--- com.squareup.okhttp3:okhttp:3.9.0
| \--- com.squareup.okio:okio:1.13.0
+--- com.android.support:design:27.1.1
| +--- com.android.support:support-v4:27.1.1
| | +--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-media-compat:27.1.1
| | | +--- com.android.support:support-annotations:27.1.1
| | | \--- com.android.support:support-compat:27.1.1 (*)
| | +--- com.android.support:support-core-utils:27.1.1 (*)
| | +--- com.android.support:support-core-ui:27.1.1 (*)
| | \--- com.android.support:support-fragment:27.1.1 (*)
| +--- com.android.support:appcompat-v7:27.1.1 (*)
| +--- com.android.support:recyclerview-v7:27.1.1
| | +--- com.android.support:support-annotations:27.1.1
| | +--- com.android.support:support-compat:27.1.1 (*)
| | \--- com.android.support:support-core-ui:27.1.1 (*)
| \--- com.android.support:transition:27.1.1
| +--- com.android.support:support-annotations:27.1.1
| \--- com.android.support:support-compat:27.1.1 (*)
+--- com.android.support:palette-v7:27.1.1
| +--- com.android.support:support-compat:27.1.1 (*)
| \--- com.android.support:support-core-utils:27.1.1 (*)
+--- com.android.support:recyclerview-v7:27.1.1 (*)
+--- com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1
| +--- com.android.support:recyclerview-v7:24.2.1 -> 27.1.1 (*)
| \--- com.android.support:support-annotations:24.2.1 -> 27.1.1
+--- com.android.support:appcompat-v7:27.1.1 (*)
+--- com.squareup.retrofit2:retrofit:2.3.0
| \--- com.squareup.okhttp3:okhttp:3.8.0 -> 3.9.0 (*)
+--- com.squareup.retrofit2:converter-gson:2.1.0
| +--- com.squareup.retrofit2:retrofit:2.1.0 -> 2.3.0 (*)
| \--- com.google.code.gson:gson:2.7 -> 2.8.1
+--- com.android.support:cardview-v7:27.1.1
| \--- com.android.support:support-annotations:27.1.1
+--- android.arch.lifecycle:extensions:1.1.1
| +--- android.arch.lifecycle:runtime:1.1.1 (*)
| +--- android.arch.core:common:1.1.1 (*)
| +--- android.arch.core:runtime:1.1.1 (*)
| +--- com.android.support:support-fragment:26.1.0 -> 27.1.1 (*)
| +--- android.arch.lifecycle:common:1.1.1 (*)
| +--- android.arch.lifecycle:livedata:1.1.1
| | +--- android.arch.core:runtime:1.1.1 (*)
| | +--- android.arch.lifecycle:livedata-core:1.1.1 (*)
| | \--- android.arch.core:common:1.1.1 (*)
| \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
+--- com.facebook.shimmer:shimmer:0.1.0
+--- com.android.support:multidex:1.0.2
+--- com.github.jinatonic.confetti:confetti:1.1.0
+--- com.github.ybq:Android-SpinKit:1.1.0
+--- com.blankj:utilcode:1.9.8
+--- com.squareup.retrofit2:converter-scalars:2.1.0
| \--- com.squareup.retrofit2:retrofit:2.1.0 -> 2.3.0 (*)
+--- io.branch.sdk.android:library:2.+ -> 2.18.1
| \--- com.android.support:support-annotations:22.2.0 -> 27.1.1
+--- com.github.bumptech.glide:glide:3.7.0
+--- com.google.android.gms:play-services-gcm:11.4.2
| +--- com.google.android.gms:play-services-base:11.4.2
| | +--- com.google.android.gms:play-services-basement:11.4.2
| | | +--- com.android.support:support-v4:25.2.0 -> 27.1.1 (*)
| | | \--- com.google.android.gms:play-services-basement-license:11.4.2
| | +--- com.google.android.gms:play-services-tasks:11.4.2
| | | +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| | | \--- com.google.android.gms:play-services-tasks-license:11.4.2
| | \--- com.google.android.gms:play-services-base-license:11.4.2
| +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| +--- com.google.android.gms:play-services-iid:11.4.2
| | +--- com.google.android.gms:play-services-base:11.4.2 (*)
| | +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| | \--- com.google.android.gms:play-services-iid-license:11.4.2
| \--- com.google.android.gms:play-services-gcm-license:11.4.2
+--- com.google.firebase:firebase-messaging:11.4.2
| +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| +--- com.google.firebase:firebase-iid:11.4.2
| | +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| | +--- com.google.firebase:firebase-common:11.4.2
| | | +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| | | +--- com.google.android.gms:play-services-tasks:11.4.2 (*)
| | | \--- com.google.firebase:firebase-common-license:11.4.2
| | \--- com.google.firebase:firebase-iid-license:11.4.2
| +--- com.google.firebase:firebase-common:11.4.2 (*)
| \--- com.google.firebase:firebase-messaging-license:11.4.2
+--- com.google.firebase:firebase-perf:11.4.2
| +--- com.google.android.gms:play-services-base:11.4.2 (*)
| +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| +--- com.google.firebase:firebase-iid:11.4.2 (*)
| +--- com.google.firebase:firebase-common:11.4.2 (*)
| \--- com.google.firebase:firebase-perf-license:11.4.2
+--- com.mixpanel.android:mixpanel-android:5.3.0
+--- me.zhanghai.android.materialprogressbar:library:1.4.2
| +--- com.android.support:appcompat-v7:26.0.2 -> 27.1.1 (*)
| \--- com.android.support:support-annotations:26.0.2 -> 27.1.1
+--- de.hdodenhof:circleimageview:2.2.0
+--- com.google.dagger:dagger:2.11
| \--- javax.inject:javax.inject:1
+--- com.google.dagger:dagger-android:2.11
| +--- com.google.dagger:dagger:2.11 (*)
| +--- com.android.support:support-annotations:25.0.0 -> 27.1.1
| +--- com.google.code.findbugs:jsr305:3.0.1 -> 1.3.9
| \--- javax.inject:javax.inject:1
+--- com.skyfishjy.ripplebackground:library:1.0.1
+--- jp.wasabeef:recyclerview-animators:2.2.7
| +--- com.android.support:support-compat:25.4.0 -> 27.1.1 (*)
| +--- com.android.support:support-core-ui:25.4.0 -> 27.1.1 (*)
| \--- com.android.support:recyclerview-v7:25.4.0 -> 27.1.1 (*)
+--- com.github.jd-alexander:LikeButton:0.2.3
| \--- com.android.support:appcompat-v7:23.2.0 -> 27.1.1 (*)
+--- com.crashlytics.sdk.android:crashlytics:2.6.8
| +--- com.crashlytics.sdk.android:beta:1.2.5
| | \--- io.fabric.sdk.android:fabric:1.3.17
| +--- io.fabric.sdk.android:fabric:1.3.17
| +--- com.crashlytics.sdk.android:crashlytics-core:2.3.17
| | +--- io.fabric.sdk.android:fabric:1.3.17
| | \--- com.crashlytics.sdk.android:answers:1.3.13
| | \--- io.fabric.sdk.android:fabric:1.3.17
| \--- com.crashlytics.sdk.android:answers:1.3.13 (*)
+--- com.android.support:support-v4:27.1.1 (*)
+--- com.android.support.constraint:constraint-layout:1.1.0
| \--- com.android.support.constraint:constraint-layout-solver:1.1.0
+--- me.relex:circleindicator:1.2.2
+--- it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15
| \--- com.android.support:appcompat-v7:24.1.1 -> 27.1.1 (*)
+--- com.jakewharton:butterknife:8.6.0
| +--- com.jakewharton:butterknife-annotations:8.6.0
| | \--- com.android.support:support-annotations:25.1.0 -> 27.1.1
| +--- com.android.support:support-annotations:25.1.0 -> 27.1.1
| \--- com.android.support:support-compat:25.1.0 -> 27.1.1 (*)
+--- com.jakewharton:kotterknife:0.1.0-SNAPSHOT
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3 -> 1.2.41
| | \--- org.jetbrains:annotations:13.0
| +--- com.android.support:support-v4:26.0.2 -> 27.1.1 (*)
| \--- com.android.support:recyclerview-v7:26.0.2 -> 27.1.1 (*)
+--- com.github.developer-shivam:Crescento:1.2.0
| +--- com.android.support:appcompat-v7:25.0.0 -> 27.1.1 (*)
| \--- com.android.support:palette-v7:25.0.0 -> 27.1.1 (*)
+--- project :luhn
| +--- com.android.support:design:27.1.1 (*)
| +--- com.android.support:appcompat-v7:27.1.1 (*)
| +--- com.android.support:support-compat:27.1.1 (*)
| +--- io.card:android-sdk:5.5.1
| \--- uk.co.chrisjenx:calligraphy:2.3.0
| \--- com.android.support:appcompat-v7:25.3.1 -> 27.1.1 (*)
+--- project :tooltip
| \--- com.android.support:support-annotations:24.0.0 -> 27.1.1
+--- com.google.android:flexbox:0.2.6
| \--- com.android.support:support-compat:25.3.0 -> 27.1.1 (*)
+--- com.github.freshdesk:freshchat-android:1.3.1
| +--- com.google.code.gson:gson:2.8.0 -> 2.8.1
| +--- com.squareup.picasso:picasso:2.5.2
| +--- com.android.support:appcompat-v7:23.4.0 -> 27.1.1 (*)
| \--- com.android.support:recyclerview-v7:23.4.0 -> 27.1.1 (*)
+--- com.google.firebase:firebase-core:11.4.2
| \--- com.google.firebase:firebase-analytics:11.4.2
| +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| +--- com.google.firebase:firebase-common:11.4.2 (*)
| +--- com.google.firebase:firebase-analytics-impl:11.4.2
| | +--- com.google.android.gms:play-services-basement:11.4.2 (*)
| | +--- com.google.firebase:firebase-iid:11.4.2 (*)
| | +--- com.google.firebase:firebase-common:11.4.2 (*)
| | +--- com.google.android.gms:play-services-tasks:11.4.2 (*)
| | \--- com.google.firebase:firebase-analytics-impl-license:11.4.2
| \--- com.google.firebase:firebase-analytics-license:11.4.2
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.41 (*)
+--- com.google.code.gson:gson:2.8.1
+--- com.firebase:firebase-jobdispatcher:0.8.5
| \--- com.android.support:support-compat:25.0.0 -> 27.1.1 (*)
\--- junit:junit:4.12
\--- org.hamcrest:hamcrest-core:1.3
答案 0 :(得分:0)
我们遇到了这样的问题。尝试使用JarJar工具https://github.com/pantsbuild/jarjar,然后将com.google.code.gson包中的代码重新打包为com.google.code.gsonlocal。有时,制造商在其OS版本中包含一些流行的库,而在运行时,开发人员会遇到问题。重新包装是解决此问题的唯一方法。
祝你好运!