我正在尝试生成签名的apk,但是出现以下错误:
Lint found fatal errors while assembling a release target.
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
}
}
...
因此,我开始研究如何解决该问题,并对此question表示了反对,我发现了一些有用的信息。
实际上,..\app\build\reports\
中有一个名为\lint-results-release-fatal.html
的文件
包含错误原因:
Duplicate Platform Classes
../../build.gradle: commons-logging 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.
../../build.gradle: `httpclient` 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.
对不起,如果阅读可能很无聊,但我正尝试逐步解释...
所以我一直在寻找,直到被困于question。基本上,建议是添加这两行代码以排除重复的类:
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
不幸的是,有一个问题,当我再次编译应用程序时,遇到了无法解决的错误:
error: cannot access ContentType
class file for org.apache.http.entity.ContentType not found
我真的认为httpclient模块的排除与上面报告的错误是联系在一起的,但是我可能是错的...
这些是一些有用的信息:
Android Studio 3.5.1
Build #AI-191.8026.42.35.5900203, built on September 25, 2019
JRE: 1.8.0_202-release-1483-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
再次感谢您阅读这里的内容,如果您有解决方案或建议,欢迎您!
14:54 05/11/19
添加其他信息,可以使您更好地了解情况
compileSdkVersion 28
defaultConfig {
applicationId "com.example.app"
minSdkVersion 22
targetSdkVersion 28
versionCode 2
versionName "21.19.08.27"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
16:35 05/11/2019
这里有依赖项
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.recyclerview:recyclerview-selection:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.williamww:silky-signature:0.1.0'
implementation 'com.afollestad.material-dialogs:core:0.9.1.0'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.weiwangcn.betterspinner:library:1.1.0'
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
implementation 'com.ajts.androidmads.sqliteimpex:library:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
10:14 08/11/2019
以前我没有提到利用useLibrary 'org.apache.http.legacy'
10:22 11/11/2019
我创建了我在以下github project上遇到的错误的副本。
所以我的目标是能够编译和使用以下类:
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
答案 0 :(得分:2)
禁用Lint不是解决方案;最好完全删除重复的依赖项:
implementation "org.apache.httpcomponents:httpmime:4.3.6"
并以预期的方式提供它(“传统”自Android API级别> = 23起适用):
useLibrary "org.apache.http.legacy"
请参见behavior changes ...或者,只需使用HttpURLConnection
,OkHttp
或Retrofit
。
org.apache.httpcomponents
也可以使用-但不能同时使用两个软件包。
为了使导入保持完全相同,一种快速而肮脏的解决方法是:
implementation "org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2"
答案 1 :(得分:1)
衷心感谢所有回答问题的人。
删除Lint控件永远不是一个好的解决方案,这要归功于Martin Zeitler,我能够解决这个问题。
在实践中,修改我设法解决的依赖项:
useLibrary 'org.apache.http.legacy'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.recyclerview:recyclerview-selection:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.williamww:silky-signature:0.1.0'
implementation 'com.afollestad.material-dialogs:core:0.9.1.0'
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'com.weiwangcn.betterspinner:library:1.1.0'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
implementation 'com.ajts.androidmads.sqliteimpex:library:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
问题和解决方案之间的区别如下:
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
答案 2 :(得分:0)
在应用程序级别gradle中添加此
buildTypes {
lintOptions {
checkReleaseBuilds false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
答案 3 :(得分:0)
选项1:
应用级优惠券
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
signingConfig signingConfigs.release
}
}
选项2:
我不建议您关闭皮棉检查,这是有原因的。相反,请检查错误并修复。
错误报告已保存到[app module]/build/reports/lint-results-yourBuildName-fatal.html.
,您可以在浏览器中打开此文件以了解错误。
如果Gradle可以更清楚地说明错误报告的生成位置,那就太好了。
答案 4 :(得分:0)
检查您的依赖关系,有时问题是库版本。更新库版本可以减少您在Android中构建APK的问题
答案 5 :(得分:0)
| customer_id | immediate_percentage |
| ----------- | -------------------- |
| 1 | 0 |
| 2 | 50 |
| 3 | 50 |
| 4 | 100 |
在您的应用程序级别gradle中添加此代码将修复该错误,但是稍后您需要找到它并修复错误,因为存在皮棉是有原因的。
这将解决
答案 6 :(得分:0)
if your want to find out the exact error then go to following path in your project
/app/build/reports/lint-results-release-fatal.html or
/app/build/reports/lint-results-release-fatal.xml
otherwise you can use
lintOptions {
checkReleaseBuilds false
abortOnError false
}