I'm configuring my build pipeline for an Android project. So far, all of my steps are working perfectly on Hosted VS2017 agent, including fetching the code, building with gradlew, publishing the artifact and deploying it to AppCenter.
However, on Hosted Ubuntu 1604, there are a few problems with gradlew step.
On VS2017 agent, this works with just: .\gradlew assembleDebug
On Ubuntu 1604, this is what I'm having right now:
chmod 775 gradlew
chmod 775 /usr/local/lib/android/sdk --> The fix I'm working on
./gradlew assembleDebug
Running the build without the 2nd line, agent will throw this exception:
What went wrong: A problem occurred configuring project ':app'.
Failed to install the following SDK components: build-tools;28.0.3 Android SDK Build-Tools 28.0.3
The SDK directory is not writable (/usr/local/lib/android/sdk)
I'm a beginner with Ubuntu... why is it not writable? I tried to chmod
but I got the exception while doing so: chmod: changing permissions of '/usr/local/lib/android/sdk': Operation not permitted
.
Which direction should I look at to solve this problem now... ? Thank you all in advance!
I had the same problem on a standard Ubuntu install.
The solution: install the Android SDK in your home directory.
The problem is, building a project with Gradle fails to work with a read-only SDK. Installing the Android SDK with apt
leaves it read-only.
More precisely, everything in /usr/
is supposed to be read-only data, so it's owned by root
with permissions set to 755
. Your user doesn't have write access to it, only the owner does. Installing the SDK in your home directory (and making sure your user owns it) should solve the issue.
I haven't seen a good way to install just the SDK. There's another SO question addressing this; one of the ways listed there ought to work. However, you may find it easier to just install Android Studio, and pick a custom location for the SDK.
Hope it helps!
Change the ownership of Android SDK:
sudo chown -R $(whoami) $ANDROID_HOME
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With