Gradle build fails due to lint classpath error on Android
In my case this error was triggered because ANDROID_HOME
environment variable wasn't set
The cause of this issue is that Gradle can't find the Android SDK. There are several ways to fix it:
Define the ANDROID_HOME
environment variable
ANDROID_HOME=your/path/to/android/sdk; export ANDROID_HOME
or Add sdk.dir
to the file local.properties
, for example on my Linux computer
sdk.dir=/home/sdeng/Android/Sdk
If you already defined ANDROID_HOME
or sdk.dir
, it still happens. Its probably something is wrong with the specific version of your Android SDK or Gradle daemon. Try to kill all Gradle processes, re-download the specific version of Android SDK.
Or you can check the SDK at directory $ANDROID_HOME/platforms/android-28
, where 28 is the compileSdkVersion
defined in build.gradle
I have figured out what the problem is. I use the build parameter 'dev' (Pbuild=dev
) to make sure that the CI (Travis, in this case) uses the mock version of my google-services.json
file placed in the app/src/dev
folder. However, I forgot to configure the 'dev' build variant in the build.gradle files of my modules.
Solution is to add the dev
build type in all modules, like this:
build.gradle
android {
...
buildTypes {
release {
...
}
debug {
...
}
dev {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Please note that you will have to do this for all the modules in your project.