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

北城余情 提交于 2019-11-27 13:37:40
Teyam

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:

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'

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

Deepak sharma

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!