我的一些用户因错误而崩溃。发生此崩溃的手机是运行 Android 9 的 Google Pixels。但是,并非所有 Pixels 都在此配置下崩溃。报告崩溃的两个设备是 Android 9 上的 Google Pixel 2 (walleye) 和 Android 9 上的 Pixel XL (marlin)。我们有使用相同设备和 Android 版本的用户没有错误,我们无法在模拟器中重现错误。
这是报告的堆栈跟踪:
java.lang.NoClassDefFoundError:
at jq.b (jq.java:3)
at jp.a (jp.java:3)
at jr.a (jr.java:19)
at com.google.android.gms.ads.internal.util.ap.a (ap.java:15)
at iv.a (iv.java:19)
at iv.run (iv.java:8)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at ac.loadClass (ac.java:4)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
at jq.b (jq.java:3)
at jp.a (jp.java:3)
at jr.a (jr.java:19)
at com.google.android.gms.ads.internal.util.ap.a (ap.java:15)
at iv.a (iv.java:19)
at iv.run (iv.java:8)
这是我的公共(public)库的 build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
libraryVariants.all { variant ->
variant.outputs.all {
def version = variant.properties.get("versionName")
def projectName = name
def formattedDate = new Date().format('yyyy-MM-dd-HHmm')
outputFileName = "${projectName}${version}-${formattedDate}.apk"
}
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 6
versionName "3.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:15.0.1'
}
}
这是我的应用程序的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp"
minSdkVersion 14
targetSdkVersion 28
versionCode 9
versionName "2.6.2"
testApplicationId "com.myapp"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
signingConfig signingConfigs.appkey
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
zipAlignEnabled true
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def relativeRootDir = output.packageApplication.outputDirectory.toPath()
.relativize(rootDir.toPath()).toFile()
def finalVersionCode = versionCode
output.versionCodeOverride = finalVersionCode
outputFileName = new File(
"$relativeRootDir/release",
outputFileName.replace(".apk", "-${finalVersionCode}.apk"))
}
}
debuggable true
jniDebuggable true
}
debug {
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '28.0.3'
productFlavors {
}
}
dependencies {
implementation project(':common')
implementation 'com.google.android.gms:play-services-ads:15.0.1'
}
最佳答案
如 this answer 中所述,在我们等待 Google 正式修复此问题时,似乎有一个临时解决方法。 map 库也受到影响。
只需将此标记放入 Manifest 文件中即可:
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
我试过了,它似乎在工作。
关于android - AdMob 运行时出现间歇性 java.lang.NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53520180/