Failed to generate apk from Android studio 3.1.1

三世轮回 提交于 2019-11-30 08:36:34

Per the Android Studio docs, your top-level build.gradle ought to have the google() repository added. Be sure to add it to the repositories under buildscript AND allprojects.

The latter one is what I missed the first time I edited this today after upgrading and that led directly to a Could not find com.android.tools.lint:lint-gradle:26.1.1. when I tried to build a release APK.

Solved (works for me) changing gradle version in the project build.gradle:

From this

classpath 'com.android.tools.build:gradle:3.1.1'

to this

classpath 'com.android.tools.build:gradle:3.0.1'

I think this version required updated libs and gradle. try to change to compileSdkVersion 27 and libaries as.

implementation 'com.android.support:support-v4:27.1.0'

and gradle ver,

classpath 'com.android.tools.build:gradle:3.1.0'

Try Setting debug to True in release mode though debuggable should be set to false in release APK but currently this is the solution i get.

release {
            debuggable true
        }

Update

Adding the following code in gradle to make it work

lintOptions {
    checkReleaseBuilds false
}

Check Settings > Build, Execution, Deployment > Compiler to see if Command-line Options contains --offline See this answer.

Ericong

please open your AndroidStudio and find click File and then find settings.

second you click compiler and then find Command-line Options: remove --offline

lintOptions {
    abortOnError false
}

//add this on gradle file inside android tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!