Cordova can't find $ANDROID_HOME - java

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

Related

Issue with environment variables JAVA and Android for using cordova (Linux 16.04)

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

Original error: Could not find 'aapt' in ["/usr/local/share/android-sdk/platform-tools/aapt"] Appium - Eclipse

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:

Can't set up Maven on Mac OSX

I am new to Mac OSX and I'm running Yosemite. I am trying to set up Maven using this official guide in order to set up a Google Cloud Messaging Backend. Here's what I did:
1) Downloaded Maven zip (version: apache-maven-3.3.9) and Unzipped it
2) As the guide says, I need to add the bin directory to my PATH variable. So I did the following in my terminal
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
The terminal didn't return any response. However when I checked to see if Maven got installed using:
mvn -version
I get a message saying:
-bash: mvn: command not found
What am I doing wrong? Did I follow the steps properly to set up Maven?
EDIT:
MVN Bin Directory path is:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
I tried all the manual steps here and still couldn't get it to work. Then I realized I can easily install it using Homebrew, much more convenient:
brew install maven
that's all you need to install maven for mac!
The $PATH is what point where your programs are, because of that you change it in order to find mvn. Actually you are pointing $PATH to $M2_HOME/bin.
You need to update $M2_HOME to one directory level before mvn bin and before update $PATH.
If this is your mvn home:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
you should use this env vars:
export M2_HOME="/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60"
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
You can also edit your ~/.profile in order to include these lines, so you don't need to type these exports whenever you open your terminal.
Do
export M2_HOME=/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9

Cordova build error ANDROID_HOME

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"

error "command not found" when run "android update project -p" in cygwin

I got a trouble. When I create and build a project java native, I got an error:
-bash: android: command not found when run "android update project -p" in cygwin.
I use windows 7, and I set environment variables : ANDROID_HOME and PATH.
I searched on this site but with them I cannot fix it.
Please help me
Try this
Go to android tools directory and type
./android update project -p
command not found typically indicates that your PATH variable is not set correctly.
In windows
set PATH = %PATH%;C:\devtools\adt-bundle-windows-x86_64\adt-bundle-windows-x86_64\sdk\tools;

Categories