[英]':app:lintVitalRelease' error when generating signed apk
我嘗試在 google play 上上傳我的 apk 並遇到錯誤消息:“您上傳了一個可調試的 APK。出於安全原因,您需要先禁用調試,然后才能在 Google Play 中發布它。了解有關可調試 APK 的更多信息。”
然后我在清單中寫了android:debuggable="false"
並再次嘗試。 我遇到了同樣的錯誤,所以我將模塊中的構建變體設置為 release 並嘗試再次生成一個 apk,但這一次,生成了這個錯誤:
Error:Gradle: Execution failed for task ':app:lintVitalRelease'.
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
}
}
...
我不建議關閉棉絨檢查,它們在那里是有原因的。 相反,檢查錯誤是什么並修復它。
錯誤報告保存到[app module]/build/reports/lint-results-yourBuildName-fatal.html
。 您可以在瀏覽器中打開此文件以了解錯誤。
如果 Gradle 可以更清楚地說明錯誤報告的生成位置,那就太好了。
我遇到了這個問題並通過添加解決了它:
lintOptions {
checkReleaseBuilds false
}
到我的android{ }
部分中的build.gradle
文件。
如果您想找出確切的錯誤,請轉到項目中的以下路徑:/app/build/reports/lint-results-release-fatal.html(或 .xml)。 最簡單的方法是,如果您轉到 xml 文件,它將准確地顯示錯誤是什么,包括錯誤在您的 java 類或 xml 文件中的位置。 關閉 lint 檢查不是一個好主意,它們的存在是有原因的。 相反,請轉到:
/app/build/reports/lint-results-release-fatal.html or
/app/build/reports/lint-results-release-fatal.xml
並修復它。
在 Kotlin 中是不同的。 首先,您需要在 app 文件夾的 build.gradel 的 Android 部分設置以下代碼。
android {
:
lintOptions {
baseline(file("lint-baseline.xml"))
}
}
然后從 IDE(分析 > 檢查代碼)或從命令行運行 lint,如下所示。
$ ./gradlew lintDebug
...
輸出打印 lint-baseline.xml 文件在 app 文件夾中的位置,但有時在 app/src 文件夾中以及 /app/lint-baseline.xml
確保您在所有string.xml
文件中定義了所有翻譯
如果您可能試圖找出問題所在,我在我的項目的以下路徑中找到了我的: /app/build/reports/lint-results-release-fatal.html (或 .xml)。
希望這可以幫助!
從android studio創建簽名apk時我遇到了同樣的問題。 我只是在android {}中對build.gradle文件進行了一些更改
lintOptions {
checkReleaseBuilds false
abortOnError false
}
***Try this***
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
signingConfig signingConfigs.release
}
}
在你的 app.gradle 文件中嘗試這 3 行。
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
}
這對我有用,我只是像這樣修改了我的 BuildTypes:
buildTypes {
release {
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
}
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
我的問題是缺少翻譯。 我有一個未翻譯的 settings.xml,因為它不需要,所以我必須在字符串中添加"translatable="false"
:
<string translatable="false" name="stringname">This string doesn't need translation</string>
只需在這里找到錯誤原因並修復它。
yourProject/app/build/reports/lint-results-release-fatal.xml
我的問題是缺少翻譯。 我有一個未翻譯的 settings.xml,因為它不需要,所以我必須在字符串中添加“translatable="false":
<string translatable="false" name="stringname">This string doesn't need translation</string>
解決這個問題 在 build.gradle (app) File Inside main Android { inside } 中使用這個
buildTypes {
// crunchPngs false // or true when png error
release {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
正如許多人所建議的那樣,嘗試從源頭修復錯誤總是更好。 檢查 lint 生成的文件
/app/build/reports/lint-results-release-fatal.html
閱讀該文件,您將被引導到錯誤的來源。 看看我的:錯誤來自不正確的視圖約束。
試試下面的代碼
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
signingConfig signingConfigs.release
}
}
Windows -> 參考 -> Android-> lint 錯誤檢查。
取消勾選運行完全錯誤......
轉到 build.gradle(Module:app)
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
}
從清單中完全刪除該語句,Eclipse 會即時為您處理。
就我而言,問題與 Google Play 所需的最低目標 API 級別有關。 它被設置為小於 26。
當我將最低目標 API 級別設置為 26 時,問題消失了。
不要禁用 lint 選項
檢查 Lint 報告中的錯誤和警告
小路:
YourAppProjectFolder\app\build\reports
解決所有錯誤和警告:)
您應該在項目級 gradle 文件中添加代碼以生成覆蓋錯誤的 apk
lintOptions {
checkReleaseBuilds false
abortOnError false
}
上面的代碼可以通過忽略它來解決問題,但它也可能導致應用程序崩潰。
好的答案在以下鏈接中:
當我將Android Gradle Plugin Version
更新為4.0.1
並將Gradle version
更新為6.1.1
時,我遇到了這個問題。
如果有人趕時間,只需將Gradle Plugin Version
降級為3.6.3
,將Gradle version
降級為5.6.4
。 它對我有用。
將 gradle 分發 url 升級為,
// android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
並將 buildscript -> 依賴項 -> 類路徑升級到,
// android/build.gradle
classpath 'com.android.tools.build:gradle:7.0.0'
為我解決了這個問題
如果在 android{ 下添加 app.gradle
lintOptions {
quiet true
abortOnError false
}
}
它會得到工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.