我的应用程序工作正常,直到今天。要与可穿戴模块(我使用Android Studio)进行一些集成,我必须将Google Play服务从6.1.0更新到7.3.0(最新版本)。我也使用外部库,我知道它工作正常,没有任何问题。
当我使用新的Google Play服务版本更新我的gradle文件时,我在运行时得到NoClassDefFoundError(在我的外部库上抱怨)。我已经尝试了一切,但没有任何作用(确保.jar正常,实际导出,清理1000次,重建,删除构建文件夹等)。如果我将Google Play服务设置为6.1.11,该应用程序将按原样运行。
这让我发疯了......
我的build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:7.3.0'
compile files('libs/mylibrary.jar')
}
错误日志:
05-06 15:23:56.544 31574-31574/com.rippll.okchat E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.rippll.okchat, PID: 31574
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/rippll/geowave/Geowave;
at com.rippll.okchat.MainActivity.onCreate(MainActivity.java:92)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rippll.geowave.Geowave" on path: DexPathList[[zip file "/data/app/com.rippll.okchat-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.rippll.okchat.MainActivity.onCreate(MainActivity.java:92)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Suppressed: java.lang.NoClassDefFoundError: com.rippll.geowave.Geowave
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.rippll.geowave.Geowave
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
答案 0 :(得分:1)
Google Wear尚不支持Google Play Services v7.x.
因此,您需要在可穿戴项目中使用Google Play Services v6.x,例如在您的build.gradle
穿戴项目文件中:
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
}
但是在您的移动(手持)项目中,您可以使用最新的v7.x库版本,如果您真的需要它,例如:
dependencies {
wearApp project(':yourWearProjectName')
compile 'com.android.support:appcompat-v7:22.0.0+'
}
答案 1 :(得分:1)
.apk的限制为~65000种方法。 Google Play服务随着每个版本的增长而增长,当您将它们包含在项目中时,您很可能跳过该方法计数限制。解决方案是仅使用您需要的模块。
请仔细阅读https://developer.android.com/google/play-services/setup.html