0

I was running Azure Pipeline build for react native app in which i am using gradle for android build and got this error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/Users/username/Library/Android/sdk' does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 34s
Error: The process '/Users/runner/runners/2.166.3/work/1/s/android/gradlew' failed with exit code 1
    at ExecState._setResult (/Users/runner/runners/2.166.3/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:816:25)
    at ExecState.CheckComplete (/Users/runner/runners/2.166.3/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:799:18)
    at ChildProcess.<anonymous> (/Users/runner/runners/2.166.3/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.163.0/node_modules/azure-pipelines-task-lib/toolrunner.js:721:19)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:920:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
##[error]Error: The process '/Users/runner/runners/2.166.3/work/1/s/android/gradlew' failed with exit code 1
Finishing: Gradle

As my ANDROID_HOME=/Users/runner/Library/Android/sdk not ANDROID_HOME=/Users/username/Library/Android/sdk i checked it by running script via YAML:

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      echo $ANDROID_HOME

So, i want to know what can be possible mistake for this error. I have tried:

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      echo $ANDROID_HOME
      echo "export ANDROID_HOME=/Users/sitefuel-dev/Library/Android/sdk" >> ~/.bashrc
      echo "export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> ~/.bashrc
      echo $ANDROID_HOME
  displayName: 'Script'

which is not working, if required any more details please ask in comments.

Rishav Singh
  • 143
  • 1
  • 3
  • 14

2 Answers2

0

It worked after change in local.properties file from:

sdk.dir=/Users/username/Library/Android/sdk

to:

sdk.dir=/Users/runner/Library/Android/sdk
Rishav Singh
  • 143
  • 1
  • 3
  • 14
0

Though your own answer is correct, it is not recommended to commit the local.properties file to version control. That file will take more priority than the ANDROID_HOME environment variable.

Dang Hai Luong
  • 1,316
  • 10
  • 14
  • 1
    but i am using hosted agent and with that i am unable to change ANDROID_HOME variable, if you have any solution please help me with that. – Rishav Singh Apr 23 '20 at 11:30
  • If you remove the local.properties file from version control, your ANDROID_HOME variable will take effect – Dang Hai Luong Apr 23 '20 at 11:34