错误:json定义了与Android现在提供的类冲突的类 [英] Error: json defines classes that conflict with classes now provided by Android

查看:577
本文介绍了错误:json定义了与Android现在提供的类冲突的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio 3上进行发布构建时出现以下错误

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

错误:错误:json定义与Android现在提供的类冲突的类.解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp代替),或使用jarjar之类的库重新打包该库. [DuplicatePlatformClasses]

以下是我的依赖项:

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'
}

这是json,但我找不到上面的哪个依赖项导致了问题.

It's saying json but I can't find which of the the above dependencies is causing the problem.

这是我跑步时得到的东西

Here is what I get when I run

gradlew assembleRelease

任务:app:lintVitalRelease /Users/kruyvanna/Projects/key/HappyKey_Android2/app/build.gradle:错误:json定义了与Android现在提供的类冲突的类.解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp代替),或使用jarjar之类的库重新打包该库. [DuplicatePlatformClasses]

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

"DuplicatePlatformClasses"类型问题的说明: 有许多库不只是复制了以下库的功能 Android平台,但使用与之完全相同的类名 在Android中提供-例如apache http类.这可能导致 发生意外崩溃.

Explanation for issues of type "DuplicatePlatformClasses": There are a number of libraries that duplicate not just functionality of the Android platform but using the exact same class names as the ones provided in Android -- for example the apache http classes. This can lead to unexpected crashes.

要解决此问题,您需要找到该库的更新版本, 不再有此问题,或重新打包库(及其所有 依赖项),例如使用jarjar工具,或者最后重写 使用不同API的代码(例如,对于http代码,请考虑使用 HttpUrlConnection或okhttp之类的库.)

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

1个错误,0个警告

失败:构建失败,并出现异常.

FAILURE: Build failed with an exception.

  • 出了什么问题: 任务':app:lintVitalRelease'的执行失败.

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

棉绒在组装发行目标时发现致命错误.

Lint found fatal errors while assembling a release target.

要继续,请修复lint标识的问题,或按如下所示修改构建脚本: ... 安卓 { lintOptions { checkReleaseBuilds为假 //或者,如果愿意,您可以继续检查发行版本中的错误, //但是即使发现错误也要继续构建: abortOnError假 } } ...

To proceed, either fix the issues identified by lint, or modify your build script as follows: ... android { lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } } ...

尝试: 使用--stacktrace选项运行以获取堆栈跟踪.使用--info或--debug选项运行,以获取更多日志输出.

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

https://help.gradle.org

推荐答案

我通过添加以下内容对其进行了修复:

I fixed it by adding:

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

到模块gradle文件,不需要删除依赖项.

to module gradle file, no removal of dependencies was needed.

这篇关于错误:json定义了与Android现在提供的类冲突的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆