简体   繁体   中英

Didn't find class “com.google.android.gms.common.app.GmsApplication”

I have got a problem when running my app on Android 4.4 with Google Play Services version 100884030. I get the following error:

FATAL EXCEPTION: main
Process: com.google.android.gms, PID: 8678
java.lang.RuntimeException: Unable to instantiate application com.google.android.gms.common.app.GmsApplication: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.app.GmsApplication" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/framework/com.google.android.ble.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.app.GmsApplication" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/framework/com.google.android.ble.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.Instrumentation.newApplication(Instrumentation.java:975)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
    ... 11 more

My Gradle settings:

compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 14 
targetSdkVersion 22
....
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile 'com.google.android.gms:play-services-ads:10.2.1'

So you see what is the problem?

Thanks !!!

I had an identical problem, I think, and it turned out that the .apk on the device was corrupted. Maybe by an internal flash storage (hardware) problem?

This is what I did:

  1. Turn on Developer Settings on the device (by tapping the Build Number seven times in the About screen of Settings).
  2. From the Developer Settings menu that appeared, turn on USB Debugging.
  3. Connect to a PC with adb installed.
  4. Find the path of the existing Google Play Services apk on the device, with adb shell pm path com.google.android.gms
  5. Use that path to pull the existing apk from the device, to check it, with adb pull /data/app/com.google.android.gms-1/base.apk (replace the path here with what you got at point 4).
  6. Check if the apk is broken, by changing its extension to .zip, and doing a zip integrity test. In my case it said classes2.dex bad CRC .
  7. Download a good apk from somewhere trusted. Another identical device would be perfect, but I didn't have one, so I got mine from apkmirror.com (make sure you pick the right variant, there are a number of them for the same version number). The one I downloaded had the same number of bytes as the one pulled from the phone, but a segment of data inside was different.
  8. Install the downloaded apk with adb install -r <downloaded file> .
  9. Reboot the device.

That's it. Everything worked after this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM