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:
Go to Manage Jenkins
Configure System
Go to Global Properties
Check Environment variables
Add ANDROID_SDK_ROOT and ANDROID_HOME environment variables in there
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
Related
So I'm getting this error
~/projects/personal-projects/react/myapp ⌚ 18:12:24
$ react-native run-android --variant=release
Scanning folders for symlinks in /Users/user/projects/personal-projects/react/myapp/node_modules (22ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installRelease)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 14.706 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I already have my android sdk installed and I also have java installed.
this is what is in my .bach_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$Home/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
I've tried adding a local.properties file and added sdk.dir pointing to my Android/sdk folder. But still this error persists. How do I fix this?
Please make file local.properties in folder android then add the following line on file
sdk.dir=/Users/apple/Library/Android/sdk(Please add your sdk path here)
You need to add ANDROID_HOME, JAVA_HOME variables in environmental variables and
tools and platform-tools in path of system to run android apk.
Setting ANDROID_HOME variable in environmental variables.
Setting JAVA_HOME variable in environmental variables.
So the solution to my problem was:
1) add my ANDROID_HOME and JAVA_HOME paths in my .bash_profile
Solution by #rana_sadam
2) Create local.properties and add sdk.dir=<PATH TO ANDROID SDK> inside the android folder.
Solution by #nisarg Thakkar
As the title states, I've set up the variable in my .bashrc like so
export ANDROID_HOME=$HOME/Android/Sdk
PATH=$PATH:$HOME/Android/Sdk:$HOME/Android/Sdk/tools
export PATH
and shows fine when I do:
printenv ANDROID_HOME
/home/chris/Android/Sdk
printenv PATH also shows the right paths.
I can cd into that directory and go into the tools directory and run ./android and it works fine (it's there).
However, doing:
ionic build android
(in a separate directory, same shell) I get:
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I have re-installed IONIC and re-installed the Android SDK as well.. Any ideas?
Ubuntu 16.10 64bit
Thanks.
Ok I figured it out, I was trying to
sudo ionic build android
instead of just
ionic build android
..and sudo has a different set of env variables. Learn something new everyday!
I started to use sudo because I was getting some permission denied errors, but it should've all been cleared, instead of resorting to super user!
I am trying to run a hybrid app on my android phone using ionic using the following command:
sudo ionic run android
However I keep receiving this error :
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting
setting it manually. Failed to find 'android' command in your 'PATH'.
Try update your 'PATH' to include path to valid SDK directory.
I have already added platform tools & tools to PATH updated ANDROID_HOME to point to my sdk root.
The ANDROID_HOME environment variable shows up when I run env and the PATH has the tools and platform tools too. Additionally I can execute android too. It launches the SDK Manager as expected.
Details:
ANDROID_HOME: /home/user/Android/Sdk
$PATH: /home/user/Android/Sdk/tools:/home/user/Android/Sdk/platform-tools
Please help! This is driving me up the wall!
Credit for this goes to #heemayl on AskUbuntu.
https://askubuntu.com/a/783805/247116
sudo sanitizes the environment and by default only keeps certain
environment variables available with modifying the values of some
(e.g. PATH).
You can pass the variable ANDROID_HOME manually:
sudo ANDROID_HOME="/actual/path" ionic run android
Or preserve the current environment:
sudo -E ionic run android
I am trying to build an ionic project. I have set up environment for ionic and android in ubuntu. But don't know why the following error is showing on terminal ...
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I have set up android home as followings ...
userPC:/codes/myApp$ export ANDROID_HOME=/opt/android-sdk-linux
userPC:/codes/myApp$ export ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform_tools
userPC:/codes/myApp$ export ANDROID_TOOLS=/opt/android-sdk-linux/tools
userPC:/codes/myApp$ PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
my android-sdk-linux is in /opt/ itself. From terminal I can run android command. So, I think environment variable is not the main issue. While I am trying to build ionic project, it shows Failed to find 'ANDROID_HOME' environment variable. I am using Android SDK Build Tools 22 and ionic latest version.
Can anyone tell me how can I solve this issue? I have searches a lot but everywhere I found to setup android sdk and environment variable path correctly. But I already have set up all these things. Thanks!
I think you are doing everything right except for the bin part.Add ANDROID_HOME environment variable to path and point out the corresponding bin directory as:
1.export ANDROID_HOME=/path/to/android/SDK
2.export PATH=$PATH:$ANDROID_HOME/bin
when you issue studio.sh command on the command line, it looks for the bin directory in the path which contain executables! studio.sh is the one in this case.
For more information,Read this
Hope this was helpful.
After long time on search. To make a final fix for this problem
Follow Theses incrustation and it will fix it Correctly
Delete your current installation of node & npm & ionic & cordova
Install nvm follow this install nvm ubuntu
Install node with nvm follow this install node via nvm
Install ionic and cordova
npm install -g cordova ionic
Never use root to install node ,npm ,ionic or cordova
Set your Android Home
export ANDROID_HOME=/path/to/android/SDK
export PATH=$PATH:$ANDROID_HOME/bin
After that its worked fine for my and ionic can see Android SDK home
I am trying to set up continuous code integration with the help of jenkins v1.592
I have an android hybrid code, which I'm, trying to build with jenkins.
I have set up environment variables for ANT_HOME, JAVA_HOME, ANDROID_HOME, and added then to the PATH respectively. I also have added nodejs and npm to the PATH.
ant version 1.9.2
java version 1.8.0_25
npm version 1.4.28
cordova android version 3.5.1
C:\Users\userName>path
gives
C:\Users\userName\AppData\Roaming\npm;C:\Program Files\nodejs;C:\whateverElse...
jenkins $WORKSPACE = C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\
now I set my cmd prompt to jenkins workspace and execute the following commands
cd myProject
cordova build android
I get BUILD_SUCCESSFUL after 24 seconds
Similarly, when I go to my local jenkins server
The jenkins dashboard is shown and I have set up myProject there and
in the project configuration I have added the lines
"cd myProject
cordova build android"
in the build step and saved the configuration.
When I try to build I get the following error
Started from command line by anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\myProject\workspace
Updating repository at revision '2014-12-02T15:20:23.437 +0530'
At revision 263
no change for repository since the previous build
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3297478415472069526.bat
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace>cd myProject
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\myProject>cordova build android
'node' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Execute Windows batch command' marked build as failure
Archiving artifacts
Finished: FAILURE
Any help would be appreciated
The same issue exists on mac OSX
Best Regards
Several things can be at play here
Did you add node to %PATH% through command line, or through the Windows UI? If done through UI, it can take affect immediatelly. If done through command line, it doesn't take affect until the next process spawns from shell, therefore Jenkins server restart is required.
Jenkins runs as "Local System" by default on Windows. You are listing C:\Users\userName as part of your paths, i.e. a user specific path. Did you set the %PATH% for all users, or just for your user userName? If it's not set for all users (or a specific user that Jenkins runs with), then Jenkins won't see it. You can change what user the service runs as.
2a. If Jenkins is running as "Local System" user, does that account have access to C:\Users\userName?
And lastly, if you set the %PATH% from command line, did you set it as a permanent entry using setx command?
In either case, from your job configuration, add a build step "Execute Windows Batch Command" and type just set (to display all environment variables) or #echo %PATH% (to see just the %PATH%) and verify that the environment is set correctly