0
votes

My gradle build is failing with the following error:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'. SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/home/ubuntu/hello_world_android/local.properties'.

This issue is in fact resolved by adding a local.properties with "sdk.dir = /opt/android-sdk-linux" to the project. However since this is intended to be used as a build machine I'd like to avoid needing to create that file for each project and instead use an environment variable. I've tried setting both ANDROID_SDK_ROOT and ANDROID_HOME to /opt/android-sdk-linux, however I keep getting the same error so long as it is not set in local.properties.

Is there any way around needing this local.properties file?

1
is ANDROID_HOME added to all users? It may be added only to the current user, or you might need to restart the machine or Studio.Ahmad Sattout
I've tried restarting the machine. ANDROID_HOME is set for the user doing the build.buffcat
Try printing the enviroment variables from bash, I think it's env or printenvAhmad Sattout

1 Answers

0
votes

After playing around with it for some time I tried moving the environment variables from .bashrc to /etc/environment and restarted. Somehow that worked, not sure why.