简体   繁体   English

在发布模式下构建应用程序时发生错误[duplicateplatformclasses]

[英]Error [duplicateplatformclasses] while building app in release mode

After updating Android Studio and updated GDAA to Google Drive REST API as GDAA is deprecated, but now I can not build my app in release mode which had no issues before. 更新了Android Studio并将GDAA更新为Google Drive REST API后,由于不推荐使用GDAA,但现在我无法以发布模式构建应用程序,而之前没有任何问题。 Here is the complete error message: 这是完整的错误消息:

org.gradle.api.GradleException: Lint found fatal errors while assembling a release target. org.gradle.api.GradleException:Lint在组装发行目标时发现了致命错误。 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 } } 要继续,请解决lint所标识的问题,或按如下所示修改构建脚本:... android {lintOptions {checkReleaseBuilds false //或者,如果愿意,您可以继续检查发行版本中的错误,//但是即使发现错误也要继续构建:abortOnError false}}

And in the lint-results-release-fatal.xml file I get these messages: lint-results-release-fatal.xml文件中,我得到了以下消息:

'commons-logging' defines classes that conflict with classes now provided by Android. “公共记录”定义了与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. 解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp替代),或使用jarjar之类的库重新打包该库。

'httpclient' defines classes that conflict with classes now provided by Android. “ httpclient”定义与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. 解决方案包括查找没有相同问题的较新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp替代),或使用jarjar之类的库重新打包该库。

Here is my gradle dependencies: 这是我的gradle依赖项:

dependencies {
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:support-core-utils:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-ads:17.1.3'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.http-client:google-http-client-gson:1.26.0'
    implementation('com.google.api-client:google-api-client-android:1.26.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
        exclude group: 'org.apache.httpcomponents'
    }
}

I tried this and this but no luck. 我想这个这个 ,但没有运气。

After trying all other solutions with no luck, I suddenly discovered that this version of Android Studio 3.3.2 does not detect libraries which are out of date and found that the library causing the problem was this: 在尝试了所有其他解决方案之后,我突然发现该版本的Android Studio 3.3.2不会检测到过时的库,并发现导致问题的库是这样的:

implementation 'com.google.http-client:google-http-client-gson:1.26.0'

As this is the suspected library from this question . 因为这是来自这个问题的可疑图书馆。

I simply updated this library to the latest version which is this at the moment: 我只是将此库更新为当前的最新版本:

implementation 'com.google.http-client:google-http-client-gson:1.28.0'

And the problem was solved. 问题解决了。

I post this question and give answer just because I could not find the right answer and for those struggling with the same problem could be the right solution. 我发布此问题并给出答案,只是因为我找不到正确的答案,而对于那些遇到相同问题的人可能是正确的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM