After I implemented Google Analytics my app crashes instantly on devices older than Lollipop.
07-22 15:42:43.831: W/dalvikvm(1815): VFY: unable to resolve virtual method 16407: Lcom/google/android/gms/analytics/internal/zzg;.getApplicationContext ()Landroid/content/Context;
07-22 15:42:43.831: D/dalvikvm(1815): VFY: replacing opcode 0x6e at 0x0003
07-22 15:42:43.831: I/dalvikvm(1815): Could not find method com.google.android.gms.internal.zzld.zzoQ, referenced from method com.google.android.gms.analytics.internal.zzf.zzV
07-22 15:42:43.831: W/dalvikvm(1815): VFY: unable to resolve static method 27402: Lcom/google/android/gms/internal/zzld;.zzoQ ()Lcom/google/android/gms/internal/zzlb;
07-22 15:42:43.831: D/dalvikvm(1815): VFY: replacing opcode 0x71 at 0x000e
07-22 15:42:43.831: W/dalvikvm(1815): VFY: unable to find class referenced in signature (Lcom/google/android/gms/internal/zzlb;)
07-22 15:42:43.831: W/dalvikvm(1815): VFY: Ljava/lang/Object; is not instance of Lcom/google/android/gms/analytics/internal/zzd;
07-22 15:42:43.831: W/dalvikvm(1815): VFY: bad arg 1 (into Lcom/google/android/gms/analytics/internal/zzd;)
07-22 15:42:43.831: W/dalvikvm(1815): VFY: rejecting call to Lcom/google/android/gms/analytics/internal/zzf;.zza (Lcom/google/android/gms/analytics/internal/zzd;)V
07-22 15:42:43.831: W/dalvikvm(1815): VFY: rejecting opcode 0x70 at 0x0002
07-22 15:42:43.831: W/dalvikvm(1815): VFY: rejected Lcom/google/android/gms/analytics/internal/zzf;.zzhT ()Lcom/google/android/gms/analytics/internal/zzv;
07-22 15:42:43.831: W/dalvikvm(1815): Verifier rejected class Lcom/google/android/gms/analytics/internal/zzf;
07-22 15:42:43.831: D/AndroidRuntime(1815): Shutting down VM
07-22 15:42:43.831: W/dalvikvm(1815): threadid=1: thread exiting with uncaught exception (group=0xb0ce1b20)
07-22 15:42:43.831: E/AndroidRuntime(1815): FATAL EXCEPTION: main
07-22 15:42:43.831: E/AndroidRuntime(1815): Process: ---, PID: 1815
07-22 15:42:43.831: E/AndroidRuntime(1815): java.lang.VerifyError: com/google/android/gms/analytics/internal/zzf
07-22 15:42:43.831: E/AndroidRuntime(1815): at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source)
07-22 15:42:43.831: E/AndroidRuntime(1815): at com.x.x.x.onCreate(x.java:22)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.os.Handler.dispatchMessage(Handler.java:102)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.os.Looper.loop(Looper.java:136)
07-22 15:42:43.831: E/AndroidRuntime(1815): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-22 15:42:43.831: E/AndroidRuntime(1815): at java.lang.reflect.Method.invokeNative(Native Method)
07-22 15:42:43.831: E/AndroidRuntime(1815): at java.lang.reflect.Method.invoke(Method.java:515)
07-22 15:42:43.831: E/AndroidRuntime(1815): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-22 15:42:43.831: E/AndroidRuntime(1815): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-22 15:42:43.831: E/AndroidRuntime(1815): at dalvik.system.NativeStart.main(Native Method)
My Gradle file (inside android block):
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "x.x.x"
minSdkVersion 14
targetSdkVersion 22
versionCode 6
versionName "0.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I use this version of Google Play Services:
compile 'com.google.android.gms:play-services-analytics:7.5.0'
I searched a lot on the web already on this subject, but couldn't find anything that solved the issue. Closest one was this answer on SO, unfortunately it didn't worked out for me: https://stackoverflow.com/a/31432568
It seems you have to import
MultiDexApplication
. I first removed proguard and then observed the exception, which was related to what I found in this link. Please go through it for elaborated answer.Try to enable MultiDex with new Android configurations, build-tools 22.0.1 had a bug that i reported on MultiDex (as you can see here: java.lang.VerifyError with API < 21).
So enable MultiDex in gradle and use build-tools 23 rc3:
import it in your dependencies (last version is 1.0.1)
And attach it to your base context in your application:
Or extend a MultiDexApplication:
Or use a MultiDexApplication in the manifest.