BVtp
BVtp

Reputation: 2480

Crash at runtime after migrating to Android Studio ( NoSuchMethodError )

I migrated to Android studio, everything seemed ok up until I tried to run the app. It got stuck in the Launcher activity and then crashed, printing:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: No direct method <init>(ILjava/lang/String;)V in class Lcom/google/android/gms/common/api/Status; or its super classes (declaration of 'com.google.android.gms.common.api.Status' appears in /data/data/com.MY PACKAGE/files/instant-run/dex/slice-google-play-........b-classes.dex)
at com.google.android.gms.measurement.zza.<init>(Unknown Source)
at com.google.android.gms.measurement.zza.zzaR(Unknown Source)
at com.google.android.gms.measurement.internal.zzn.zziJ(Unknown Source)
at com.google.android.gms.measurement.internal.zzz.zza(Unknown Source)
at com.google.android.gms.measurement.internal.zzw.<init>(Unknown Source)
at com.google.android.gms.measurement.internal.zzaa.zzDj(Unknown Source)
at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source)
at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1759)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1728)
at android.app.ActivityThread.installProvider(ActivityThread.java:5534)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5105)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5045)
at android.app.ActivityThread.access$1600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1459)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)

Upvotes: 5

Views: 6849

Answers (4)

Anurag
Anurag

Reputation: 1170

Add google play services dependencies

dependencies {
    compile 'com.google.android.gms:play-services:8.4.0'//update with latest version
}

or this,

compile 'com.google.android.gms:play-services-gcm:8.4.0'//update with latest version

Clean the project & rebuild

Upvotes: -1

ViliusK
ViliusK

Reputation: 11555

For me, I got similar crash of missing method, because I had to update recently added library version in my build.gradle file.

Upvotes: 0

Luca Thiede
Luca Thiede

Reputation: 3443

For me it was the Problem, that the versions of different of my play service dependencies differed, like

dependencies {
    compile 'com.google.android.gms:play-services-gcm:8.4.0' /different version
    compile 'com.google.android.gms:play-services-maps:9.0.2'
    compile 'com.google.android.gms:play-services-location:9.0.2'
}

should be changed to

dependencies {
    compile 'com.google.android.gms:play-services-gcm:9.0.2'
    compile 'com.google.android.gms:play-services-maps:9.0.2'
    compile 'com.google.android.gms:play-services-location:9.0.2'
}

I hope it works for you or somebody running into the same issue.

Upvotes: 10

Tanim reja
Tanim reja

Reputation: 2188

add this line to your manifest file

<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

and also add this to your gradle

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}

second solution:

add this to your launcher activity's onCreate() method

public void onCreate(Bundle arguments) {
 Context context = this.getInstrumentation().getTargetContext().getApplicationContext();
  MultiDex.install(context );
  super.onCreate(arguments);
...
}

or

needed to add this in class that extends Application:

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

for more detail : link 1 , link 2 , link 3, link 4

Hope it works..

Upvotes: 1

Related Questions