13

When I try to generate a signed APK, I found this issue :

10:58 Generate Signed APK: Errors while building APK. You can find the errors in the 'Messages' view. No cached version of com.android.tools.lint:lint-gradle:26.1.1 available for offline mode.

this is my android studio details :

Android Studio 3.1.1
Build #AI-173.4697961, built on April 4, 2018
JRE: 1.8.0_152-release-1024-b02 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

this block for signing the apk :

  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.releaseconfig
    }
    debug {

        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                'proguard-rules.pro'
    }

}  signingConfigs {
    releaseconfig {
        keyAlias 'release_key'
        keyPassword 'xxxxx'
        storeFile file('xxxxxx)
        storePassword 'xxxx'
    }
}
Kopi Bryant
  • 1,300
  • 1
  • 15
  • 30
Abrd
  • 278
  • 1
  • 2
  • 10
  • 1
    https://stackoverflow.com/questions/22607661/no-cached-version-of-com-android-tools-buildgradle0-9-1-available-for-offline?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa Please check this – srinu Apr 10 '18 at 10:17
  • try this delete `.gradle` folder from your project and rebuild the project and generate apk file. – Lucifer Apr 10 '18 at 10:21

8 Answers8

20

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.

MartyMacGyver
  • 9,483
  • 11
  • 47
  • 67
4

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'
Giovesoft
  • 580
  • 6
  • 21
  • Does not work, got new error like this: "Expected a name but was STRING at line 1 column 99 path $[0].apkInfo.versionName" – Babul Mirdha Apr 13 '18 at 13:30
  • @BabulMirdha take a look here: https://stackoverflow.com/questions/49809977/expected-a-name-but-was-string-at-line-1-column-99-path-0-apkinfo-versionname – Giovesoft Apr 13 '18 at 13:43
  • This worked for me. This was even highlighted in Android Studio as a suggested thing to change. Thanks! – TheGrandPackard Apr 24 '18 at 21:39
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'
SRB Bans
  • 3,096
  • 1
  • 10
  • 21
1

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
}
Mohsin
  • 902
  • 3
  • 23
  • 49
1

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

ehartwell
  • 1,667
  • 19
  • 18
0

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

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

Anantha Raju C
  • 1,780
  • 12
  • 25
  • 35
0
lintOptions {
    abortOnError false
}

//add this on gradle file inside android tag

samuel samer
  • 301
  • 3
  • 6
0

Please use Analyze > Inspect Code to inspect your code

If your app could be compiled and running just fine but you failed to generate sign APK. For me, after running inspection it shows me a few errors in my code. I fixed all those errors then I could build sign APK just fine. Check this Answer for more option to fix this

Master Zzzing
  • 524
  • 6
  • 18