最近在用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
}