Errors while building APK. You can find the errors in the 'Messages' view.
阿新 • • 發佈:2019-01-01
最近在用Android Studio打包簽名apk時遇到了一個問題,經過查詢資料,順利解決。
問題一:Messages報錯如下:
Error: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的build.gradle裡的android{}中新增如下程式碼,然後再次執行Generate Signed Apk。
android{
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
問題二:Messages報錯如下:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/cardview/BuildConfig.class
解決方法:
那就是說明你在工程中libs資料夾或是build.gradle中引用了重複的依賴包或是依賴工程,自己Ctrl+N,輸入BackStackState查詢一下是哪個包重複,那麼就刪除相應的libs中的jar包依賴,然後通過compile方式進行引用即可。
問題三:Messages報錯如下:
dexDebug ExecException finished with non-zero exit value 2
解決方法:
需要在gradle中配置下面的程式碼,原因是引用了多個libraries檔案
defaultConfig {
multiDexEnabled true
}