【问题标题】:Intermittent java.lang.NoClassDefFoundError at runtime from AdMobAdMob 在运行时出现间歇性 java.lang.NoClassDefFoundError
【发布时间】:2018-11-28 13:06:15
【问题描述】:

我的一些用户因错误而崩溃。发生此崩溃的手机是运行 Android 9 的 Google Pixel。但是,并非所有 Pixel 都在此配置下崩溃。报告崩溃的两台设备是 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)

这是我的公共库的 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'
}

【问题讨论】:

  • 我也遇到了这个问题。你找到解决办法了吗?
  • 不幸的是,还没有。这是非常不一致的。没有押韵或理由。 :(
  • 你找到解决这个问题的方法了吗?我的任何应用程序用户都没有联系我告诉我他们有一些问题。也许这只是在 GP 控制台上注册的?

标签: android admob noclassdeffounderror


【解决方案1】:

this answer 所述,在我们等待 Google 正式修复此问题时,似乎有一个临时解决方法。地图库也受到影响。

只要把这个标签放到 Manifest 文件中:

<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />

我试过了,它似乎工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-15
    • 2019-02-21
    • 1970-01-01
    • 2021-05-16
    • 2015-01-29
    • 1970-01-01
    • 2017-07-22
    • 1970-01-01
    相关资源
    最近更新 更多