简体   繁体   中英

Error on some devices - couldn't find class 'com.google.android.gms.measurement.internal.zzz'

I am working on an Android Custom Launcher. The application runs perfectly on some phones but do not start on others. On launching the application the following error occurs.

E/dalvikvm﹕ Could not find class 'com.google.android.gms.measurement.internal.zzz', referenced from method com.google.android.gms.measurement.internal.zzv.zzaL

E/AndroidRuntime﹕ FATAL EXCEPTION: main

java.lang.VerifyError: com/google/android/gms/measurement/internal/zzv
            at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1651)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1622)
            at android.app.ActivityThread.installProvider(ActivityThread.java:5016)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:4590)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4530)
            at android.app.ActivityThread.access$1500(ActivityThread.java:155)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1385)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5300)
            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:830)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:646)
            at dalvik.system.NativeStart.main(Native Method)

So after a lot of searching i came to know that this problem was due to the multidexing. On some phones multidexing don't work. May be due to their Android Version. However i fixed this by introductng an application class

public class MyApplication extends Application {

    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

and in menifest i entered the name in application tag like:

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/xxxxxx"
        android:label="@string/app_name"
        android:manageSpaceActivity="xxxxxxxxxx"
        android:theme="@style/AppTheme" >

+) Building Apps with Over 65K Method will cause this Error.

+) When your application and the libraries it references reach a certain size ( DEX file of your application can have total number of methods upto 65,536 including Android framework methods, library methods, and methods in your own code), you encounter build errors that indicate your app has reached a limit of the Android app build architecture.

+) To resolve it, include Multidex Configuration in your build.gradle like the highlighted one in picture, along with this override the attachBaseContext(Context base) method in your Application class with the below content.

public class YourParentApplication extends Application {

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
 }
}

Add this in you Androidmanifest.xml:

<application
    android:name=".YourParentApplication"
    android:allowBackup="true"
    android:icon="@drawable/radiius_logo"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/MyMaterialTheme">

For more information about Multidex refer these sites: http://developer.android.com/tools/building/multidex.html

How to enable multidexing with the new Android Multidex support library

在此输入图像描述

It is due to multidexing, your application uses more than 64k methods update your

build.gradle(app level) with

defaultConfig{

.....

multiDexEnabled true

}

dependencies{

.....

compile 'com.android.support:multidex:1.0.1'

}

and

@Override

protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

in your Application Class

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