AndroidStudio realse打包apk 报错Lint found fatal errors while assembling a release target

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>

在此记录一下

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值