Hello stackoverflow gang,
I'm trying to build android sample app with command "cordova build android" and always get Error: Failed to find 'ANDROID_HOME' as you can see in attached image I setup path properly. I've no idea what I doing wrong. Could you please suggest me how to solve this problem.
/* Add more info */
I'm using mac osx 10.11 .
I can run android command from terminal and open Android SDK Manager.
I can build ios successful with command "cordova build ios"
Thank you
Karun
Set path in Environmental variable
In windows:-
System properties->Environmental variable->System variables->click new and add
variable name->ANDROID_HOME
variable path->sdk path (i.e. .../sdk)
I faced similar issue on my Mac 10.9.5 while building android app. Go through the below steps:
First download the android sdk for mac from here.
Then in .bash_profile file, set path like below:
export ANDROID_HOME=/Users/anand.gupta/android-sdk-macosx
export PATH=/Users/anand.gupta/android-sdk-macosx/build-tools:/Users/anand.gupta/android-sdk-macosx/platform-tools:/Users/anand.gupta/android-sdk-macosx/tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
Now download Android 4.4.2(API 19) from your android manager. (Optional)
Make sure you have ant installed. Check using: ant -version.
You can use the latest cordova but if the issue is still persist then use cordova (3.5.0-0.2.7), but if you want to upgrade or downgrade the cordova, remove the existing one using:-
sudo npm uninstall -g cordova
Then install cordova without sudo
sudo npm install -g cordova#3.5.0-0.2.7
And after downloading the android(4.4.2), create an android virtual device using the command:
android avd
Let me know if helps solving your problem or not. Happy coding! :)
Thanks guys for your suggestions. Finally I found the answer just grant permission to my project by using command "sudo chown -R macuser /Users/macuser/applications/myproject" and using build command without sudo "cordova build android"
Related
I found a lot of solutions but they didn't help me.
I defined variables in /home/username/.zshrc
export ANDROID_HOME="/home/username/Android/Sdk"
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
And variables were defined because:
echo $ANDROID_HOME -> /home/username/Android/Sdk
echo $ANDROID_HOME/tools -> /home/zemil/Android/Sdk/tools
echo $ANDROID_HOME/platform-tools -> /home/zemil/Android/Sdk/platform-tools
Also command below works fine:
> ionic cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28
Gradle: installed /usr/share/java/gradle/bin/gradle
I try to build a project
> sudo ionic cordova build --release android --verbose
...
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'adb' command at /usr/bin but no 'platform-tools' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK/platform-tools directory.
In tried many files with env variable for my linux
In manjaro linux it needs to write env variables only in file:
/etc/environment
export ANDROID_HOME="/home/{USER_NAME}/Android/Sdk"
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
So cordova works well in this case
Change USER_NAME to your linux user name
Also should refresh paths ($ source ./environment) or restart system
I am trying to build an android app with cordova. I have followed each step and I have solved many issues but in this last step, when I input the command "cordova build", I get the following message:
"Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/home/javiertxu/Android/Sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio"
I will show here the file ~/.bashrc with my environment variables.
Image with ~/.bashrc content file
One strange thing is when I "echo JAVA_HOME" it prints an empty message, then I think that the real issue is relationed with that (you can see it in the following image) empty echo image, or maybe the file .bashrc is not the correct file which I should to modify.
When I use the command "readlink -f $(which java)" I get this direction "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java". If I print $ANDROID_HOME I get /home/javiertxu/Android/Sdk.
This is all the information I can provide, so I hope that someone can help me solve this.
Thanks.
Image of .profile:
~/.profile content
I am currently trying to learn about Appium Automated Testing. Everything is setup perfectly on my Mac.
All my environmental variables are set up correctly :
export ANDROID_HOME=/Users/abc/Library/Android/sdk
export
PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
However when I run the eclipse program, eclipse throws an error saying:
remote stacktrace: UnknownError: An unknown server-side error occurred
while processing the command. Original error: Could not find 'aapt' in
["/usr/local/share/android-sdk/platform-tools/aapt","/usr/local/share/android-sdk/emulator/aapt","/usr/local/share/android-sdk/tools/aapt","/usr/local/share/android-sdk/tools/bin/aapt"].
Do you have Android Build Tools installed at
'/usr/local/share/android-sdk'?
So my question is why eclipse is looking for Android SDK tools in usr/local , my sdk tools are located in
/Users/abc/Library/Android/sdk.
How can I tell eclipse to look for the appt,adb, etc in my User folder and not the admin usr folder.
My expectation is that your PATH variable has /usr/local/share/android-sdk/emulator/aapt entry and it is resolved before your additions of the ANDROID_HOME variable.
So either remove that Android SDK which lives under /usr/local/share/android-sdk/ from your operating system like:
brew cask uninstall android-sdk
or amend your PATH variable definition so your "good" Android SDK installation goes before anything else like:
export PATH=$JAVA_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH
See Appium Java Code examples for more information regarding proper setup of Appium environment. You might also want to check the integrity of the infrastructure setup using appium-doctor
appium-doctor --android
I just struggled with on MacOS Catalina 10.15.3, Appium 1.10.1, Appium Doctor v.1.13.0 trying to set up Android with Appium.
Make sure you are changing the correct file. You have 3 possible locations.
~/.bash_profile
~/.profile
~/.zshrc
I was editing my ~/.bash_profile instead of ~/.zshrc you can have a situation where you are setting the correct path but not in the right file.
If your trying to get going with Android Appium in Mac here is what I put in my ~/.zshrc at the bottom
# Android Paths for Appium
export ANDROID_HOME=/Users/**PUT_YOUR_USER_NAME_HERE_WITHOUT_STARS**/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform_tools
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
Also if you don't want to edit in a terminal-based editor use the following command to open the files in a text editor.
open -e .bash_profile
open -e .zshrc
open -e .profile
After editing do not forget to save.
Quit your Terminal.
Run Appium_Doctor
The following post helped me out a lot when setting up my Appium
appium-workshop/Appium Mac Installation Instructions
https://github.com/isonic1/appium-workshop/blob/master/Appium%20Mac%20Installation%20Instructions.md
If you have a system-wide eclipse installation, it usually won't read your environment variables from your .bashrc or .bashprofile, but from /etc/environment.
If you don't want to modify this file, or if it doesn't exist on a Mac, then you can always set the variables at a project level. This is done in the "Environment" tab of the configuration (run, debug, external tools,...) you're running within Eclipse, like this:
I got the following error when I opened my project in Android Studio:
Error:Execution failed for task ':app:prepareComAndroidSupportAnimatedVectorDrawable2531Library'.
Unable to unzip 'C:\Users\Dharmawan's\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\animated-vector-drawable\25.3.1\animated-vector-drawable-25.3.1.aar' to 'C:\Users\Dharmawan's.android\build-cache\13e16c0d483386c8c964b3557f261a501ceb749b\output' or find the cached output 'C:\Users\Dharmawan's.android\build-cache\13e16c0d483386c8c964b3557f261a501ceb749b\output' using the build cache at 'C:\Users\Dharmawan's.android\build-cache'
Unfortunately, executing Android Studio as administrator on Linux, you won't update the IDE.
In this case, I used the chmod +777 command, to resolve this problem, but the big problem will be the computer vulnerability.
The command is sudo chmod +777 -R /home/your_user/Android/ or the path where is located the program.
Studio cannot unzip the file due to folder's privileges. To solve it execute Studio with administrator privileges.
In linux terminal (usually in /usr/local/include/android-studio/bin) type:
sudo ./studio.sh
In windows execute Studio as "Administrator".
I am trying to convert Volley to a jar file. However a step in the guide has me input into the command prompt:
"android update project -p .
ant jar "
but I get that android is not a command. I have never used this command before today and the guide assumes that it is already on my system. Can someone explain how to install and use the "android" command