java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener
Asked Answered
C

2

18

I upgraded my android studio to 2.1.3. And now I am getting following error

java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V in class Landroid/support/v4/view/ViewCompatLollipop; or its super classes (declaration of 'android.support.v4.view.ViewCompatLollipop' appears in /data/data/com.restroshop.restroowner/files/instant-run/dex/slice-internal_impl-24.2.0_7c318f8d2adb03d07a9def5d35a14e39204ecef2-classes.dex)
at android.support.v4.view.ViewCompat$LollipopViewCompatImpl.setOnApplyWindowInsetsListener(ViewCompat.java:1619)
at android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(ViewCompat.java:2924)
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:425)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:312)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:277)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.restroshop.restroowner.splash.SplashScreen.onCreate(SplashScreen.java:65)
at android.app.Activity.performCreate(Activity.java:6033)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)

in line setContentView(R.layout.activity_splash_screen);

My code snippet is

public class SplashScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen); // this line giving error
    }

I have no idea what exactly went wrong while upgrading.

Cavitation answered 19/8, 2016 at 23:47 Comment(3)
Please check that every "com.android.support:xxx:..." on your grade file is 24.2.0Phelips
Thanks @Idemay. It worked for me.Cavitation
Awesome, check developer.android.com/topic/libraries/support-library/… , the v4 library is now split.Phelips
T
24

I upgraded my android studio to 2.1.3. And now I am getting following error

I am also suffering with same issue. But I was resolved as the following way.

Reason of this exception is AppcompatActivity derived from the v7 library. so we should provide proper library based on your gradle and SDK.

  1. should update the dependency Libraries also.
  2. Right click on the project in the project structure -> select Open module settings and select dependencies tab -> Library module-> then type which library you want add to the project. It shows the latest libraries based on your gradle updated version, then select latest one and remove the existing one.

For example In my project "appcompat-v7" version is 23.4.0 then I was changed to 24.2.0.

Toxoid answered 23/8, 2016 at 15:2 Comment(0)
U
19

I had this error coming due to multiple version of same library.

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.jakewharton:butterknife:8.5.1'

The butterknife was adding the new version of the appcombat lib. I checked it using

./gradlew -q dependencies app:dependencies

The way gradle works it automatically updates the library to new library version, if available. So I added the following code

compile('com.jakewharton:butterknife:8.5.1') {
    exclude module: 'appcompat-v7'
    exclude group: 'com.android.support'
}

It worked fine after that.

Ulric answered 9/5, 2017 at 13:54 Comment(2)
You bought back the coder in me... i was struggling from last two days..and the thing was exclude module this saved me...so a thumbs up to you bro...Anatto
I can understand. I was stuck myself on this problem. It is quite frustrating!Ulric

© 2022 - 2024 — McMap. All rights reserved.