java.lang.IllegalAccessError: Method 'void android.support.v4.content

前端 未结 4 529
心在旅途
心在旅途 2020-12-03 05:11

I updated playservice in my sdk and I got this error. And I am not able to access GCM Token. Before update sdk my project work perfectly.

I waste my whole day in i

相关标签:
4条回答
  • 2020-12-03 05:43

    Set a API version check of > 22 cause I got the same issue

    java.lang.IllegalAccessError: Method 'void android.widget.ProgressBar.setProgress(int, boolean)' is inaccessible to class
    

    and I fixed it like:

    if (Build.VERSION.SDK_INT > 22)
        progressBar.setProgress(currentProgress, true);
    else
        progressBar.setProgress(currentProgress);
    

    check here setProgress Issue

    0 讨论(0)
  • 2020-12-03 05:53

    I had the same problem after some digging I found out that facebook sdk was depending on the new version of google support libraries than I have compiled on.

    You can check the dependencies with gradle command

    ./gradlew app:dependencies
    

    Ensure that all the dependency libraries has same version. If not then you can exclude that dependency using

    compile ('com.facebook.android:facebook-android-sdk:[4,5)'){
        exclude module: 'support-v4'
        exclude group: 'com.android.support'
    }
    

    then later add the required the dependency you have compiled your project on, In my case

    compile 'com.android.support:support-v4:23.1.0'

    0 讨论(0)
  • 2020-12-03 05:56

    I have Android Studio 2.3 and my problem was solved by uninstalling the "Android Support Library (Obsolete)" from SDK Tools.

    0 讨论(0)
  • 2020-12-03 06:04

    Please check your declared dependencies. As discussed in the given documentation there are three different types of direct dependencies in the app/ module's build.gradle file.

    Sample dependencies are as follows:

    android {...}
    ...
    dependencies {
        // The 'compile' configuration tells Gradle to add the dependency to the
        // compilation classpath and include it in the final package.
    
        // Dependency on the "mylibrary" module from this project
        compile project(":mylibrary")
    
        // Remote binary dependency
        compile 'com.android.support:appcompat-v7:25.0.1'
    
        // Local binary dependency
        compile fileTree(dir: 'libs', include: ['*.jar'])
    }
    

    Furthermore, as answered by @Diego Giorgini in a related SO post,

    The issue you are experiencing is due to an incompatibility between play-services / firebase sdk v9.0.0 and com.android.support:appcompat-v7 >= 24 (the version released with android-N sdk)

    With this, you may want to try the suggested fix:

    You should be able to fix it by targeting an earlier version of the support library. Like:

    compile 'com.android.support:appcompat-v7:23.4.0'

    You may want to also check the other suggestions in the following SO posts:

    • IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM
    • Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update.
    0 讨论(0)
提交回复
热议问题