简体   繁体   中英

Android SDK location not found

I'm trying to test and build my android app using Jenkins locally on my machine. I'm on Linux and I launched Jenkins through docker by running the following command:

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins

Then I opened up my browser and fired Jenkins from localhost:8080 . After the initial setup, I added the environment variable with following steps:

  1. Go to Manage Jenkins
  2. Configure System
  3. Go to Global Properties
  4. Check Environment variables
  5. Add ANDROID_SDK_ROOT and ANDROID_HOME environment variables in there
  6. Click Apply and Save

Here's how it looks in Jenkins on my machine: 在此处输入图像描述

Basically followed steps from this answer: https://stackoverflow.com/a/29231580/4954322

I also added the same environment variables in my ~/.zshrc file too:

export ANDROID_SDK_ROOT=/home/harry/Android/Sdk/
export ANDROID_HOME=/home/harry/Android/Sdk/

I'm using Use Gradle Wrapper in the Build section of the project configuration with the following commands:

clean
testDebugUnitTes
assembleDebugBuild

After following all of these steps, my build is still failing with message:

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 '/var/jenkins_home/workspace/MeteorDebugBuild/local.properties'.

My question is how can I fix this error and why the build is still failing with all of this setup?

I think docker containers are isolated from your Jenkins, which means that inside the container there are no environment variables ANDROID_SDK_ROOT and ANDROID_HOME . What you want is:

docker run -e ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT} -e ANDROID_HOME=${ANDROID_HOME} -p 8080:8080 -p 50000:50000 jenkins/jenkins

I have not checked whether it works, but I hope it may be the solution to your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM