Saturday, July 9, 2022

[SOLVED] SDK directory is not writable when building Android project on Ubuntu agent of Azure Pipelines

Issue

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!


Solution

Change the ownership of Android SDK:

sudo chown -R $(whoami) $ANDROID_HOME


Answered By - Eytan Manor
Answer Checked By - Marie Seifert (WPSolving Admin)