Android API 24 < Crashes with java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher

huangapple go评论98阅读模式
英文:

Android API 24 < Crashes with java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher

问题

以下是翻译好的部分:

我的应用在启动时每次都崩溃,并显示以下错误:java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher。这只在运行在 Android API 24 以下版本的设备上发生。我尝试过更改 Gradle 版本和插件,以及包含 com.google.guava 依赖,但都没有起作用。以下是完整的堆栈跟踪:

java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
    at com.google.common.base.Splitter.on(Splitter.java:127)
    at io.grpc.internal.GrpcUtil.<clinit>(GrpcUtil.java:197)
    at io.grpc.internal.AbstractManagedChannelImplBuilder.<clinit>(AbstractManagedChannelImplBuilder.java:90)
    at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:46)
    at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:26)
    at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76)
    at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(GrpcCallProvider.java:113)
    at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(GrpcCallProvider.java:256)
    at com.google.firebase.firestore.remote.GrpcCallProvider$$Lambda$5.call(GrpcCallProvider.java)
    at com.google.android.gms.tasks.zzy.run(com.google.android.gms:play-services-tasks@@17.1.0:2)
    at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
    at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$Lambda$1.run(ThrottledForwardingExecutor.java)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)

除了上面的错误外,我还经常遇到以下异常:

W/System.err: io.reactivex.exceptions.UndeliverableException: java.lang.NoClassDefFoundError: io.grpc.okhttp.OkHttpChannelBuilder
    at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
    at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:69)
    at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.NoClassDefFoundError: io.grpc.okhttp.OkHttpChannelBuilder

我的项目级 Gradle 文件如下:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.android.tools.build:gradle:4.0.2'
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
        classpath 'com.google.firebase:perf-plugin:1.3.1'  // Performance Monitoring plugin
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

这是我的应用级 Gradle 文件:

plugins {
    id "com.github.triplet.play" version "2.8.0"
}
// 其他部分省略
dependencies {
    // 其他依赖
    implementation 'com.google.guava:guava:29.0-android'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

注意:由于你要求只返回翻译好的部分,我已经省略了一些代码块和内容。如果你需要更多帮助,请随时提问。

英文:

My app is crashing everytime it starts up with: java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher. This only happens on devices running below android API 24. I have tried amending the Gradle versions and plugins as well as including the com.google.guava dependency but it did not work. Here is the full stack trace:

java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
at com.google.common.base.Splitter.on(Splitter.java:127)
at io.grpc.internal.GrpcUtil.&lt;clinit&gt;(GrpcUtil.java:197)
at io.grpc.internal.AbstractManagedChannelImplBuilder.&lt;clinit&gt;(AbstractManagedChannelImplBuilder.java:90)
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:46)
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:26)
at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76)
at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(GrpcCallProvider.java:113)
at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(GrpcCallProvider.java:256)
at com.google.firebase.firestore.remote.GrpcCallProvider$$Lambda$5.call(GrpcCallProvider.java)
at com.google.android.gms.tasks.zzy.run(com.google.android.gms:play-services-tasks@@17.1.0:2)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java:54)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$Lambda$1.run(ThrottledForwardingExecutor.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)

I also get this exception constantly along with the above one:

W/System.err: io.reactivex.exceptions.UndeliverableException: java.lang.NoClassDefFoundError: io.grpc.okhttp.OkHttpChannelBuilder
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:69)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: io.grpc.okhttp.OkHttpChannelBuilder

My project level gradle file looks like this:

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath &#39;com.google.gms:google-services:4.3.3&#39;
classpath &#39;com.android.tools.build:gradle:4.0.2&#39;
classpath &quot;androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0&quot;
classpath &#39;com.google.firebase:firebase-crashlytics-gradle:2.1.1&#39;
classpath &#39;com.google.firebase:perf-plugin:1.3.1&#39;  // Performance Monitoring plugin
}
}
allprojects {
repositories {
google()
jcenter()
maven { url &quot;https://jitpack.io&quot; }
}
}

This is my app level gradle file:

plugins {
id(&quot;com.github.triplet.play&quot;) version &quot;2.8.0&quot;
}
apply plugin: &#39;com.android.application&#39;
android {
compileSdkVersion 29
defaultConfig {
applicationId &quot;...&quot;
minSdkVersion 21
targetSdkVersion 29
versionCode 48
versionName &quot;4.0.4&quot;
testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
}
signingConfigs {
release {
...
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39;
}
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile(&#39;proguard-android.txt&#39;),
&#39;proguard-rules.pro&#39;
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions &quot;version&quot;
productFlavors{
spanish{
dimension &quot;version&quot;
applicationId &quot;...&quot;
buildConfigField &#39;String&#39;, &#39;PRIMARY_COLOR&#39;, &#39;&quot;#ffc400&quot;&#39;
buildConfigField &#39;String&#39;, &#39;ACCENT_COLOR&#39;, &#39;&quot;#C60B1E&quot;&#39;
buildConfigField &#39;String&#39;, &#39;LANG_CODE&#39;, &#39;&quot;es&quot;&#39;
}
italian{
dimension &quot;version&quot;
applicationId &quot;...&quot;
buildConfigField &#39;String&#39;, &#39;PRIMARY_COLOR&#39;, &#39;&quot;#008C45&quot;&#39;
buildConfigField &#39;String&#39;, &#39;ACCENT_COLOR&#39;, &#39;&quot;#CD212A&quot;&#39;
buildConfigField &#39;String&#39;, &#39;LANG_CODE&#39;, &#39;&quot;it&quot;&#39;
}
}
packagingOptions {
exclude &#39;META-INF/DEPENDENCIES&#39;
}
}
play {
...
}
dependencies {
//debugImplementation &#39;com.squareup.leakcanary:leakcanary-android:2.0-beta-5&#39;
implementation fileTree(include: [&#39;*.jar&#39;], dir: &#39;libs&#39;)
implementation &#39;androidx.appcompat:appcompat:1.1.0&#39;
implementation &#39;com.google.firebase:firebase-core:17.4.4&#39;
implementation &#39;com.google.firebase:firebase-firestore:21.7.1&#39;
implementation &#39;com.google.firebase:firebase-crashlytics:17.1.1&#39;
implementation &#39;br.com.simplepass:loading-button-android:2.2.0&#39;
implementation &#39;com.google.firebase:firebase-perf:19.0.8&#39;
implementation &#39;com.google.firebase:firebase-analytics:17.4.4&#39;
implementation &#39;com.google.firebase:firebase-functions:19.0.2&#39;
implementation &#39;com.google.android.play:core:1.8.0&#39;
implementation &#39;com.google.firebase:firebase-config:19.2.0&#39;
implementation &#39;com.github.triplet.gradle:play-publisher:2.8.0&#39;
implementation &#39;com.google.guava:guava:29.0-android&#39;
}
apply plugin: &#39;com.google.gms.google-services&#39;
apply plugin: &#39;com.google.firebase.crashlytics&#39;
apply plugin: &#39;com.google.firebase.firebase-perf&#39;

答案1

得分: 2

如果你将

implementation 'com.google.guava:guava:29.0-android'

替换为

implementation ('com.google.guava:guava') {
version {
strictly '29.0-android'
}
}

它应该可以工作。

英文:

If you replace

implementation &#39;com.google.guava:guava:29.0-android&#39;

for this

implementation (&#39;com.google.guava:guava&#39;) {
version {
strictly &#39;29.0-android&#39;
}
}

it should work.

huangapple
  • 本文由 发表于 2020年10月16日 02:37:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/64377782.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定