Runtime crash after switching to Android Studio (NoSuchMethodError)

I switched to Android studio, everything seemed fine until I tried to run the application. He was stuck in the activities of Launcher, and then crashed by 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) 
+5
source share
4 answers

For me there was a problem that different versions of my dependencies in the game service were different, for example

 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' } 

Hope this works for you or someone who is facing the same issue.

+10
source

add this line to the 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 onCreate () launch activity

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

or

you need to add this to the class that extends Application:

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

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

Hope this works.

+1
source

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

0
source

Add google play services dependencies

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

or that,

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

Clean project and rebuild

-1
source

Source: https://habr.com/ru/post/1247354/


All Articles