我正在开发Eclipse中的遗留项目,需要更新Google Play服务,特别是Google Analytics和Admob。
尝试通过从Android SDK /extras/
文件夹中复制JAR文件来获取9.2.0旧方法时,我发现由于Google切换到支持Android Studio的AAR文件而不再可能。
我发现this GitHub project将所有Google Play服务AAR模块扩展到各个Android项目中。我已按照此处的说明(https://github.com/dandar3/android-google-play-services-README)下载并导入了适用于Google Analytics和Admob的项目。
我的项目成功编译没有错误,因此可以正确访问和链接所有类。
但是,在运行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();
从我的研究中,我看到的是对影响姜饼设备的(旧)错误的引用,但我不认为这适用于此。
编辑:我的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"
}
答案 0 :(得分:0)
So next day I added the Android library "play-services-basement" as a dependency to my project and everything worked. Didn't realize I needed to add that as a dependency directly to my own project since admob/analytics projects implicitly added it as well.