AndroidStudio realse打包apk 报错Lint found fatal errors while assembling a release target
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
}
}
解决方法一:
在build.gradle中添加
lintOptions {
checkReleaseBuilds false
abortOnError false
}
如下:
android {
signingConfigs {
release {
keyAlias 'key0'
keyPassword 'j*******'//此处屏蔽
storeFile file('D:/androidstudio_keystore/jytest.jks')
storePassword 'j*******'//此处屏蔽
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.jytest.test"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}
buildToolsVersion '28.0.2'
//new add
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
解决方法二:
引起该错误的原因可能是在AndroidManifest.xml中相同activity重复注册的问题引起的,大家可以检查一下。
我在这里报错的问题是已经注册过了MyApplication,后面把HeadSetReceiver这个广播类放在MyApplication里面,注册时相当于又注册了一次,打包测试时正常安装,但是release时报以上错误,将HeadSetReceiver这个广播类提出单独放,再release,一切OK啦~~~,不需要添加lintOptions ......
<application
android:name="com.jytest.application.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
......
<receiver android:name="com.jytest.application.MyApplication.HeadSetReceiver">
<intent-filter>
<action android:name="android.intent.action.HEADSET_PLUG" android:enabled="true"></action>
</intent-filter>
</receiver>
在此记录一下