英文:
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.<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)
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 '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" }
}
}
This is my app level gradle file:
plugins {
id("com.github.triplet.play") version "2.8.0"
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "..."
minSdkVersion 21
targetSdkVersion 29
versionCode 48
versionName "4.0.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
...
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "version"
productFlavors{
spanish{
dimension "version"
applicationId "..."
buildConfigField 'String', 'PRIMARY_COLOR', '"#ffc400"'
buildConfigField 'String', 'ACCENT_COLOR', '"#C60B1E"'
buildConfigField 'String', 'LANG_CODE', '"es"'
}
italian{
dimension "version"
applicationId "..."
buildConfigField 'String', 'PRIMARY_COLOR', '"#008C45"'
buildConfigField 'String', 'ACCENT_COLOR', '"#CD212A"'
buildConfigField 'String', 'LANG_CODE', '"it"'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
play {
...
}
dependencies {
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-5'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-firestore:21.7.1'
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
implementation 'br.com.simplepass:loading-button-android:2.2.0'
implementation 'com.google.firebase:firebase-perf:19.0.8'
implementation 'com.google.firebase:firebase-analytics:17.4.4'
implementation 'com.google.firebase:firebase-functions:19.0.2'
implementation 'com.google.android.play:core:1.8.0'
implementation 'com.google.firebase:firebase-config:19.2.0'
implementation 'com.github.triplet.gradle:play-publisher:2.8.0'
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'
答案1
得分: 2
如果你将
implementation 'com.google.guava:guava:29.0-android'
替换为
implementation ('com.google.guava:guava') {
version {
strictly '29.0-android'
}
}
它应该可以工作。
英文:
If you replace
implementation 'com.google.guava:guava:29.0-android'
for this
implementation ('com.google.guava:guava') {
version {
strictly '29.0-android'
}
}
it should work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论