Reactnative $JAVA_HOME path error - android

zzz#zzz-PC ~/AndroidStudioProjects/Example $ react-native run-android
Scanning 555 folders for symlinks in /home/zzz/AndroidStudioProjects/Example/node_modules (16ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-9-oracle
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
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/android-setup.html
Anyone can tell what's the problem, after I've run "react-native run-android" command. I've changed my JAVA_HOME path in /etc/environment, it still failed.

You need to be pointing to a jdk, currently you are pointing to a JVM. Go here and download the appropriate jdk and install it. Then switch your JAVA_HOME variable to the new path to the jdk.

Related

JAVA_HOME is not set error, after running React-native app

PS C:\Users\Prabhudev\react-projects\react-native\myFirstApp> react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
First Add the JDK and JRE paths to the System Variable "Path"
like below:
Secondly, Add the JAVA JDK path to the USER variable as JAVA_HOME. as shown below:
Restart the cmd and go to the app directory and run the app with react-native run-android
Voila:

While installing IONIC, ANDROID_HOME variable is set but getting 'Failed to find 'ANDROID_HOME' environment variable'

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!

sudo ionic run android not working

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

ANDROID_HOME environment variable issues with Appium

I am trying to run Appium on the command line with OSX El Capitan to test an Android application. I have been able to use Appium many times with the GUI version but have not had the same luck in the terminal. The issues I am facing stem from setting the $ANDROID_HOME environment variable. I have read other posts regarding this problem but the solutions have not helped me.
I have the following in my bash_profile :
export ANDROID_HOME=/Users/adamjakiela/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
I then run source ~/.bash_profile and am able to start the SDK by running the android command. I can also print the environment variable:
echo $ANDROID_HOME
/Users/adamjakiela/Library/Android/sdk
But then, when I run Appium on the command line I receive the following message which eventually leads to other problems:
warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path.
I can also run the Appium doctor and see the following:
Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.
Additionally, I have installed all the build tools for the applicable versions of Android and have had no problem build my applications or using the Appium GUI version by pointing it to the $ANDROID_HOME location.
Why are the errors shown by Appium inconsistant with the fact that the $ANDROID_HOME environment variable is set and that other applications are able to use the Android SDK?

Meteor 1.2 Failed to find ANDROID_HOME

Problem: Meteor cannot find my Android SDK when I try to meteor add-platform android on Linux Mint.
I've set my PATH variable: (echo $PATH)
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jimmy/Android/Sdk/tools:/home/jimmy/Android/Sdk/platform-tools
I've got my ANDROID_HOME variable: (echo $ANDROID_HOME)
/home/jimmy/Android/Sdk
But still, when I run sudo meteor add-platform android --verbose I get:
Adding platform Android to Cordova project
% Adding android project...
android: added platform
Checking Cordova requirements for platform Android
Your system does not yet seem to fulfill all requirements to build apps for
Android.
Please follow the installation instructions here:
https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on-Linux
Status of the requirements:
✓ Java JDK
✗ Android SDK: 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.
✗ Android target: Android SDK not found. Make sure that it is installed. If it
is not at the default location, set the ANDROID_HOME environment variable.
✗ Gradle: Could not find gradle wrapper within Android SDK. Could not find
Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
Okay, so I figured it out? (I guess)
So, I had already had my PATH and ANDROID_HOME set and everything, I could do echo $PATH and echo $ANDROID_HOME and it would print fine; but when I would run the different commands, it wouldn't work.
however, when I run sudo -s and then the commands, it works fine.
Cheers
ANDROID_HOME must be set to Android/Sdk folder. In my case (Ubuntu) it is:
export ANDROID_HOME="/home/***<user name>***/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Put this lines at the end of ~/.profile:
$ gedit ~/.profile
Then $ source ~/.profile
I had the same issue (and now I am stuck to Android target), but to solve Android SDK,
go to Android studio and ensure you remove everything from Android 6,
then that you have Android 5.1.1 installed (with v22 of the platform),
restart your console (I had to restart the laptop)
and normally it doesnt appear again (btw you dont need to use sudo normally)
It's possible that since you're using SUDO - that the PATH / ANDROID_HOME are not present in the root user's session. So try either:
sudo -s
export PATH=...
export ANDROID_HOME=...
meteor ...
or avoid using sudo.

Categories

Resources