Error: json defines classes that conflict with classes that are now provided by Android

I got the following error when creating a release on Android Studio 3

Error: Error: json defines classes that conflict with the classes that are now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, to use httpclient HttpUrlConnection or okhttp) or to repack the library using something like jarjar. [DuplicatePlatformClasses]

Below are my dependencies:

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.0.1' compile 'com.android.support:support-v4:26.0.1' compile 'org.greenrobot:eventbus:3.0.0' compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' compile 'com.evernote:android-job:1.2.0' compile 'com.amitshekhar.android:android-networking:1.0.0' compile 'com.facebook.stetho:stetho:1.5.0' compile "me.tatarka.redux:redux-core:0.10" compile "me.tatarka.redux:redux-android:0.10" compile "me.tatarka.redux:redux-android-lifecycle:0.10" compile "me.tatarka.redux:redux-thunk:0.10" annotationProcessor "org.immutables:value:2.5.5" // <-- for annotation processor provided "org.immutables:value:2.5.5" // for annotations provided "org.immutables:builder:2.5.5" // for annotations compile "me.tatarka.redux:redux-monitor:0.10" testCompile 'junit:junit:4.12' } 

He says json, but I cannot find which of the above dependencies is causing the problem.

This is what I get when I run

 gradlew assembleRelease 

Task: application: lintVitalRelease / Users / kruyvanna / Projects / key / HappyKey _Android2 / app / build.gradle: Error: json defines classes that conflict with the classes that are now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, to use httpclient HttpUrlConnection or okhttp) or to repack the library using something like jarjar. [DuplicatePlatformClasses]

Explanation for questions like "DuplicatePlatformClasses": There are several libraries that duplicate not only the functionality of the Android platform, but using the same class names as those provided in Android - for example, apache http classes. This can lead to unexpected crashes.

To solve this problem, you either need to find a newer version of the library that no longer has this problem or repack the library (and all its dependencies) using something like a jarjar tool or finally rewrite the code to use different APIs (for example, for http code, consider using an HttpUrlConnection or a library like okhttp.)

1 error, 0 warnings

FAILURE: assembly failure with exception.

  • What went wrong: Execution failed for task ': app: lintVitalRelease'.

    Lint detected fatal errors in assembling the release target.

    To continue, fix the problems identified by lint, or change the construction of the script as follows: ... android {lintOptions {checkReleaseBuilds false // Or, if you want, you can continue to check for errors in releases, // but continue to build even if it is detected errors: abortOnError false}} ...

  • Try: Run with the --stacktrace option to get a stack trace. Run with the -info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

+7
java json android
source share
4 answers

Add this to your app/build.gradle

 configurations { all { exclude module: 'commons-logging' } } 
+2
source share

I fixed it by adding:

 configurations { all { exclude group: 'org.json', module: 'json' } } 

in the gradle module, no dependency removal is required.

+1
source share

Go to the command line and look at the dependency tree. This will give you a list of everything your application uses:

 ./gradlew dependencies 
0
source share

I added the dependencies one by one and found this, causing an error

 compile "me.tatarka.redux:redux-monitor:0.10" 
0
source share

All Articles