gpt4 book ai didi

android - Lint 在组装发布目标时发现 fatal error - gradle 错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:10:45 25 4
gpt4 key购买 nike

我将 AS 3.1 与 gradle-4.5-all.zip 和主要的 build.gradle 一起使用:

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}

allprojects {
repositories {
jcenter()
google()
}
}

app-level build.gradle 如下所示:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
useLibrary 'org.apache.http.legacy'

defaultConfig {
applicationId "com.example"
minSdkVersion 14
targetSdkVersion 27
versionCode 6
versionName "1.00"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

dependencies {
implementation 'ch.acra:acra:4.6.1'
implementation 'commons-validator:commons-validator:1.5.0'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.google.zxing:core:3.3.0'
}

当我在 AS 3.1 下为我的手机设置 debug 版本时工作正常,但是当我尝试制作 release 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
}
}

正如我在 lint-results-release-fatal.html 中看到的那样,原因是:

lint-results-release-fatal.html

我不想更改 lintOptions 来抑制这个错误,因为它不能解决问题,它只是隐藏它。此外,当我使用

implementation files('libs/commons-validator-1.5.0.jar')

代替

implementation 'commons-validator:commons-validator:1.5.0'

release apk 编译时没有任何错误消息。是 gradle 错误还是什么!?

P.S. 我附上了一个文件 androidDependencies.txt .包 commons-logging 根本没有出现在依赖项中!分析这个文件怎么可能得到上述问题的解决方案?

最佳答案

the release apk is compiled without any error messages. Is it a some gradle bug or what!?

似乎该依赖项有一个与 Android 本身冲突的包。它在没有 implementation 并手动添加它的情况下工作的原因,可能是当您添加它以从 maven 存储库下载它时它会下载所需的包,这就是问题出现的时候。

无论如何,在这些情况下的解决方案可能是使用 the latest version :

implementation 'commons-validator:commons-validator:1.6'

或者,排除如下:

implementation ('commons-validator:commons-validator:1.5.0') {
exclude group: 'commons-logging', module: 'commons-logging'
}

注意:以下部分没有帮助(对于此问题),因为错误提示:

Commons-logging defines classes that conflict with classes now provided by Android

你可以在IDE终端中运行./gradlew app:dependencies深入查看哪个与Android本身有冲突,然后如上排除。

关于android - Lint 在组装发布目标时发现 fatal error - gradle 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52912899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com