Reputation: 5901
I am trying to build an Android app using Gradle on Ubuntu 18.04. Android Studio is not installed o the machine (I use Eclipse for development but maintain a gradle toolchain).
The toolchain has worked on a different machine running Ubuntu 16.04. However, it does not work with gradle 3.4.1, which ships with 18.04, so I had to upgrade my build config. On the 18.04 machine, I changed the dependency
classpath 'com.android.tools.build:gradle:2.1.2'
to
classpath 'com.android.tools.build:gradle:2.3.0'
and changed
buildToolsVersion "23.0.3"
to
buildToolsVersion "25.0.3"
Now when I run gradle build
, I get the following error message:
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
However, I have ANDROID_HOME
set and pointing to ~/bin/android-sdk-linux
, which is the root dir of my Android SDK setup. Also, I have Android SDK build tools 25.0.3 installed locally.
What gives?
Upvotes: 2
Views: 943
Reputation: 5901
Apparently Gradle does not honor ANDROID_HOME
, despite the error message saying otherwise.
As a workaround,
echo sdk.dir=$ANDROID_HOME >> local.properties
in the project root dir has fixed this (after also ensuring I was using the correct JDK version and had all submodules checked out).
Oddly, however, on a different computer (also running Ubuntu 18.04) the same app builds without local.properties
being present.
Upvotes: 2
Reputation: 106
If there is no local.properties, just go ahead and create one in parallel to gradle directory.
Then add this line, sdk.dir=/Users/YOUR_USERNAME/Library/Android/sdk
Upvotes: 0