java.lang.NoClassDefFoundError:解析失败:Lcom / google / android / gms / common / GooglePlayServicesUtil;

时间:2015-08-19 07:23:33

标签: java android eclipse

08-19 12:47:30.421: D/AndroidRuntime(2440): Shutting down VM
08-19 12:47:30.439: E/AndroidRuntime(2440): FATAL EXCEPTION: main
08-19 12:47:30.439: E/AndroidRuntime(2440): Process: com.programmingtechniques.gcmdemo, PID: 2440
08-19 12:47:30.439: E/AndroidRuntime(2440): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GooglePlayServicesUtil;
08-19 12:47:30.439: E/AndroidRuntime(2440):     at com.programmingtechniques.gcmdemo.MainActivity.checkPlayServices(MainActivity.java:84)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at com.programmingtechniques.gcmdemo.MainActivity.onCreate(MainActivity.java:36)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.Activity.performCreate(Activity.java:5937)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.ActivityThread.access$800(ActivityThread.java:144)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.os.Looper.loop(Looper.java:135)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at android.app.ActivityThread.main(ActivityThread.java:5221)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at java.lang.reflect.Method.invoke(Native Method)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at java.lang.reflect.Method.invoke(Method.java:372)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-19 12:47:30.439: E/AndroidRuntime(2440): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.GooglePlayServicesUtil" on path: DexPathList[[zip file "/data/app/com.programmingtechniques.gcmdemo-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-19 12:47:30.439: E/AndroidRuntime(2440):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-19 12:47:30.439: E/AndroidRuntime(2440):     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-19 12:47:30.439: E/AndroidRuntime(2440):     ... 15 more
08-19 12:47:30.439: E/AndroidRuntime(2440):     Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.GooglePlayServicesUtil
08-19 12:47:30.439: E/AndroidRuntime(2440):         at java.lang.Class.classForName(Native Method)
08-19 12:47:30.439: E/AndroidRuntime(2440):         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-19 12:47:30.439: E/AndroidRuntime(2440):         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-19 12:47:30.439: E/AndroidRuntime(2440):         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-19 12:47:30.439: E/AndroidRuntime(2440):         ... 16 more
08-19 12:47:30.439: E/AndroidRuntime(2440):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

1 个答案:

答案 0 :(得分:2)

如果您使用的是gradle,请将此添加到build.gradle:

compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-analytics:7.8.0'
compile 'com.google.android.gms:play-services-appindexing:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'

所有这些都包含包含此类的基本包。选择你需要的那个。