【问题标题】:NoClassDefFoundError with Google Play Services 9.2.0 (Admob)Google Play 服务 9.2.0 (Admob) 的 NoClassDefFoundError
【发布时间】:2016-11-12 18:45:39
【问题描述】:

我在 Eclipse 中处理一个遗留项目,需要更新 Google Play 服务,特别是 Analytics 和 Admob。

在尝试通过从 Android SDK /extras/ 文件夹中复制 JAR 文件来获取 9.2.0 时,我发现由于 Google 切换到支持 Android Studio 的 AAR 文件,这不再可能。

我发现this GitHub project 将所有 Google Play 服务 AAR 模块扩展为单独的 Android 项目。我已经下载并导入了适用于 Analytics 和 Admob 的项目,如此处所示 (https://github.com/dandar3/android-google-play-services-README)。

我的项目成功编译,没有错误,因此所有类都可以正确访问和链接。

但是,在运行 Android 6.0.1 的 Nexus 5 上启动时,我在启动时经常收到此消息:

Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.ads.internal.client.zze>
Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.ads.internal.client.zze>
Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.ads.internal.client.zze>
Shutting down VM
FATAL EXCEPTION: main
Process: com.example.app, PID: 22307
java.lang.NoClassDefFoundError: com.google.android.gms.ads.internal.client.zze
    at com.google.android.gms.ads.internal.client.zzm.<init>(Unknown Source)
    at com.google.android.gms.ads.internal.client.zzm.<clinit>(Unknown Source)
    at com.google.android.gms.ads.internal.client.zzm.zziw(Unknown Source)
    at com.google.android.gms.ads.internal.client.zzad.<clinit>(Unknown Source)
    at com.google.android.gms.ads.AdRequest.<clinit>(Unknown Source)
    at com.google.android.gms.ads.AdRequest$Builder.<init>(Unknown Source)
    at com.example.AndroidLauncher$1.handleMessage(AndroidLauncher.java:102)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

第 102 行指的是这个,在启动时出现:

AdRequest adRequest = new AdRequest.Builder().build();

根据我的研究,我所看到的只是对影响 Gingerbread 设备的(旧)错误的引用,但我认为这不适用于这里。


编辑:我的 build.gradle 文件按要求。不确定是否相关,因为我没有使用它来将依赖项链接到 Google Play 服务,但无论如何都是这样:

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'org.robovm:robovm-gradle-plugin:1.11.0'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0.0-SNAPSHOT'
    ext {
        appName = 'sticknodes'
        gdxVersion = '1.5.5'
        roboVMVersion = '1.14.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    }
}

project(":android-pro") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "org.robovm:robopods-google-mobile-ads-ios:1.14.0"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        compile fileTree(dir: 'libs', include: '*.jar')
    }
}

project(":ios-pro") {
    apply plugin: "java"
    apply plugin: "robovm"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        compile fileTree(dir: 'libs', include: '*.jar')
    }
}

project(":core") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.googlecode.mp4parser:isoparser:1.1.14"
        compile fileTree(dir: 'libs', include: '*.jar')
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

【问题讨论】:

  • 你能发布你的 Gradle 文件吗?
  • @nitinsh99 当然,用它编辑了我的问题。
  • 您可以尝试在您的依赖项中添加:compile "com.google.firebase:firebase-ads:9.0.0" 吗?确保清理您的项目并重新同步 gradle。
  • @nitinsh99 我以前玩过这个。我按照你的建议做了,Gradle 没有下载任何新内容。所以我把com.android.tools.build:gradle从1.3.1改成了2.0.0。现在它只是在尝试刷新 Gradle 依赖项时给我这个错误:pastebin.com/pHz7Tn4F
  • 继续并更改了包装器版本,如错误所述,必须清理一些其他内容以使其刷新依赖项。仍然没有下载任何新内容,因此项目只是显示“无法解析为类型”错误。

标签: java android admob google-play-services proguard


【解决方案1】:

所以第二天我将 Android 库“play-services-basement”作为依赖项添加到我的项目中,一切正常。没有意识到我需要将它作为依赖项直接添加到我自己的项目中,因为 admob/analytics 项目也隐式添加了它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多