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>

在此记录一下

发布了11 篇原创文章 · 获赞 3 · 访问量 7858
展开阅读全文

Android studio build时候报错

01-26

FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'MyApplication'. > Could not resolve all dependencies for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:1.5.0. Required by: :MyApplication:unspecified > Could not resolve com.android.tools.build:gradle:1.5.0. > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.5.0/gradle-1.5.0.pom'. > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.5.0/gradle-1.5.0.pom'. > Connection to https://jcenter.bintray.com refused * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 45.925 secs Process finished with exit code 1 本地是有gradle的,但是好像build的时候还需要去下载似的 这个是运行出来的gradlew compileDebug --stacktrace 出来的Log信息,求指教 D:\work\Androidstudio\project\MyApplication>gradlew compileDebug --stacktrace Downloading https://services.gradle.org/distributions/gradle-2.8-all.zip Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:649) at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:275) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at org.gradle.wrapper.Download.downloadInternal(Download.java:58) at org.gradle.wrapper.Download.download(Download.java:44) at org.gradle.wrapper.Install$1.call(Install.java:61) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览