No static method setOnApplyWindowInsetsListener exception in Android

后端 未结 7 1476
借酒劲吻你
借酒劲吻你 2020-12-07 01:01

I downloaded yesterday Android Studio 2.1.3 (before I worked with 1.5) and now I have this exception:

java.lang.NoSuchMethodError: No static method setOnAppl         


        
相关标签:
7条回答
  • 2020-12-07 01:37

    here is the issue :

    i also faced this this issue once, and i found that i was using invalid dependency in my gradle :

    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    

    use this version of design or some other library, it solved my problem.

    Thanks

    0 讨论(0)
  • 2020-12-07 01:39

    Changing the support library versions to the latest solved my problem.

    Snapshot of the constants defined in gradle.properties:

    BUILD_TOOLS_VERSION=23.0.2
    COMPILE_SDK_VERSION=23
    TARGET_SDK_VERSION=23
    DESIGN_SUPPORT_VERSION=24.2.0 //changed from 23.2.0
    APPCOMPAT_VERSION=24.2.0 //changed from 23.2.0
    ANDROID_SUPPORT_VERSION=24.2.0 //changed from 23.2.0
    

    Snapshot of the dependencies I added:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile ("com.android.support:appcompat-v7:${project.APPCOMPAT_VERSION}"){
            exclude module: 'support-v4'
        }
        compile "com.google.android.gms:play-services-analytics:${project.PLAY_SERVICES_VERSION}"
        compile "com.google.android.gms:play-services-gcm:${project.PLAY_SERVICES_VERSION}"
        compile "com.android.support:design:${project.DESIGN_SUPPORT_VERSION}"
        compile "com.android.support:recyclerview-v7:${project.ANDROID_SUPPORT_VERSION}"
        compile "com.android.support:cardview-v7:${project.ANDROID_SUPPORT_VERSION}"
        compile "com.google.android.gms:play-services-location:${project.PLAY_SERVICES_VERSION}"
        compile "com.google.android.gms:play-services-maps:${project.PLAY_SERVICES_VERSION}"
        /* google maps*/
        compile 'com.squareup.picasso:picasso:2.4.0'
        compile 'com.google.code.gson:gson:2.5'
        compile 'com.jakewharton:disklrucache:2.0.2'
        compile project(':volley')
    }
    
    0 讨论(0)
  • 2020-12-07 01:47

    I had same issue. I tried to run my code on another system with latest downloaded version of Android SDK (API 24). compileSdkVersion of my code was 23. So, what I did is I opened app.iml file (located in app module) and found version of components installed and updated them in build.gradle(app module) file.

    Like,

    compile 'com.android.support:design:23.1.1'
    

    to

    compile 'com.android.support:design:24.2.0'
    

    And also updated compileSdkVersion to 24, buildToolsVersion to 24.0.1, targetSdkVersion to 24. Now my code runs fine.

    Hope it helps.

    0 讨论(0)
  • 2020-12-07 01:47

    It's should be the same problem as java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener

    Try to only use the 24.2.0 version for all the "com.android.support:xxx:..." in your gradle file.

    BTW, now, support v4 is split (https://developer.android.com/topic/libraries/support-library/revisions.html#24-2-0-v4-refactor). Try to use only what you need ;)

    0 讨论(0)
  • 2020-12-07 01:51

    I have also face this type of error after update android studio 2.1.2 to 2.1.3, so I change AppCompat version from 23.4.0 to 24.2.0. Hope it will work! Good luck :)

    0 讨论(0)
  • 2020-12-07 01:53

    I was facing the same issue.

    These are my configuration: compileSdkVersion 25 buildToolsVersion "25.0.2"

    Dependency: compile 'com.android.support:support-v4:25.3.1'

    I tried many things but finally it worked by updating Android SDK platform tools.

    Steps:

    1. Open SDK Manager
    2. Android SDK -> SDK tools
    3. Select Android SDK Platform - Tools (26.0.0) & Android SDK Tools (26.0.2)
    4. After downloading clean & build your project.
    0 讨论(0)
提交回复
热议问题