Verify that ANDROID_HOME has been added to your path - java

I am trying to set up react-native (for Android) on my macOs but the app is failing to build so I am retrying it by following this link:
https://reactnative.dev/docs/environment-setup
In one of the steps, we have to add something to our $HOME/.bash_profile. I open it using vi .bash_profile and then paste the commands. Next, I am asked to 'Verify that ANDROID_HOME has been added to your path by running echo $PATH.'
When I run echo $PATH., I get this:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users//Library/Android/sdk/emulator:/Users//Library/Android/sdk/tools:/Users//Library/Android/sdk/tools/bin:/Users//Library/Android/sdk/platform-tools
I don't see the word ANDROID_HOME anywhere. Is there a problem here? Maybe with the path? Or is it being correctly verified?
I am running this in the root directory.
EDIT:
I managed to successfully setup everything and run the default AwesomeProject as well (from the root directory). However, when I try to run another project, it does not work. I see this:
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 '/Users/mycompany/insta/app/android/local.properties
What's the problem? Which steps from the setup should I repeat inside this particular folder? Should I make another bash profile? I don't get what path to add in the local.properties

You can find all the environment variable documentation here: https://developer.android.com/studio/command-line/variables
According to the dev website:
If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
If ANDROID_HOME is defined but does not exist or does not contain a valid SDK
installation, the value in ANDROID_SDK_ROOT is used instead.
Try echo $ANDROID_HOME. If that returns nothing try echo $ANDROID_SDK_ROOT. One of them should return your SDK directory. If not export one of them in your bash_profile as a env variable.
Easiest solution is to do a quick install of Android Studio and selecting the option to install SDK tools. This easily sets up your environment for android. All you need to do is add the SDK tools directory to your path once the install completes.
AVD images are pedantic if you change any directories and throw SDK_ROOT errors if you change things. Most problem free solution is to either download and run the installer or download the SDK tools, run the install and specify the path directory.

Your PATH variable is being correctly modified.
Echo your ANDROID_HOME variable to see what it is. It should be /Users//Library/Android/sdk/. When you use this variable in PATH, it's automatically being expanded when you echo it. You won't see "ANDROID_HOME" in the PATH.

create local.properties file inside android folder and paste sdk.dir={ANDROID_SDK_PATH}, then restart react-native server.

This problem has to do with two things:
local.properties file
ANDROID_HOME (SDK path)
Firstly,
For the local.properties, first make sure that the file is there in your project folder/android. If the file is there open it and make sure that the sdk.dir is pointing to your android SDK directory.
and if the file is not there create it and paste this:
sdk.dir = /Users/USERNAME/Library/Android/sdk
Replace USERNAME with your username
Secondly,
make sure that the ANDROID_HOME is there in the system variables and is also pointing to your android SDK directory.
or create new system variable named ANDROID_HOME and set the value your android SDK directory path if it's not there

Related

mvn is not recognized as an internal or external command

I followed all the tutorials and tried to use maven.
I run win 7, and downloaded maven 3.5.4.
I placed the zip file under c:\Maven and extract it in that location.
I navigate to Environment variables and create Variable M2, and put value %M2_HOME%\bin.
I navigate to Environment variables and create Variable M2_HOME and put value C:\Maven\apache-maven-3.5.4
I navigate to System variables and in Path I added %M2_HOME%\bin
In System variables the variable JAVA_Home has value C:\Program Files\Java\jdk1.8.0_65
What am I missing?
[][maven path]
[][java path]
[][env variable]
[][system variable]
[][java home]
[][command line]
[][maven path]
When using Windows, I prefer to install with chocolatey.org
You can put Java, mvn, etc on your machine and forget about it.
Similar to the package management system in Linux
Resolve this is creating M2_HOME & MAVEN_HOME and editing Path variable. You can refer to this link
The same issue I faced, In your screen shot you are missing the LICENSE, NOTICE, and README.txt.
That was because you should unzip and then copy, you would have just copied without unzipping the files.
Make sure you get the LICENSE file is in the folder. That resolved this issue.

what is different between ANDROID_HOME & ANDROID_SDK_HOME

I have 2 directory that look same,
ANDROID_HOME=C:\Android\sdk
ANDROID_SDK_HOME=C:\Users[user]\AppData\Local\Android\Sdk
whats the different?
can I set it in one dir?
Based on the documentation:
ANDROID_HOME
ANDROID_HOME, points to the SDK installation directory. This has been deprecated, use ANDROID_SDK_ROOT instead.
If you continue to use it, the following rules apply:
If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
If ANDROID_HOME is defined but does not exist or does not contain a valid SDK installation, the value in ANDROID_SDK_ROOT is used instead.
ANDROID_SDK_HOME
The root of the user-specific directory where all configuration and AVD content is stored
can I set it in one dir?
Ideally you shouldn't, since they serve different purpose.
Seems like the accepted answer is no longer valid. The current docs say:
ANDROID_SDK_ROOT, which also points to the SDK installation directory, is deprecated.
Source table: https://developer.android.com/studio/command-line/variables#envar
I got this message -
com.android.prefs.AndroidLocationsException: ANDROID_SDK_HOME is set to the root of your SDK: D:\AndroidStudio\SDK
ANDROID_SDK_HOME was meant to be the parent path of the preference folder expected by the Android tools.
It is now deprecated.
To set a custom preference folder location, use ANDROID_USER_HOME.
It should NOT be set to the same directory as the root of your SDK.
To set a custom SDK location, use ANDROID_HOME.

how to compile JShop2 src

I'm working with JShop2 GitHub. I'm having trouble with the installation; it says:
After unzipping the JSHOP2 zipped file in any directory, set the
CLASSPATH environment variable to include (replacing JSHOP2_DIRECTORY
with the directory where JSHOP2 is unzipped):
in Windows: JSHOP2_DIRECTORY\bin\antlr.jar;JSHOP2_DIRECTORY\bin\JSHOP2.jar;
How can I set these environmental variables? I don't have bin folder as shown in the path --> JSHOP2_DIRECTORY\bin\
I just read that i need to compile src to get bin folder, but I don't know how to do that. Please help.
You can still add the environmental variables even if the bin folder doesn't exist yet. Just make sure you restart your command prompt after you added the new environmental variables, for them to be picked up.
As for building the source in Windows, looking at the readme, their make.bat seems to be missing. You can create an issue in github to notify them. Meanwhile, you can use something like MinGW to run make on Windows.
After installing MinGW, you may have to execute
copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
if make.exe didn't get created during the installation. Then you should be able to build the project by executing make from your jshop2 root folder.

setting class path in Java

I used to run eclipse on my laptop. I have installed and used Secunia PSI application in order to update the apps, but once I done that I cannot run Eclipse.
This is what I have:
I set the PATH to the directory which contains javaw.exe app. The path at the PATH variable is the same as of CLASSPATH variable.
So, what are your resolutions? Done, it works now. I just simply needed to add '.;' at the end of the path link at the PATH.
Cheers
As the error message clearly states, Eclipse cannot find the entire JVM.
Add the directory that contains javaw.exe to your PATH.
Better to add JAVA_HOME as a new system variable in the same screen where you see the class path by clicking New and providing the folder location for JAVA root installation folder e.g. below:
Variable Name= JAVA_HOME
Variable Value= C:\Program Files\Java\jdk1.7.0_09

Gdal for windows 7(x32)

How do I connect to the gdal eclipse. I tried all the ways it does not work.
How do I connect to the gdal eclipse. I tried all the ways it does not work.
All the time issue
java.lang.UnsatisfiedLinkError: D: \ Document \ JAVA \ Gdal \ gdalLibrary \ gdaljni.dll: Can't find dependent libraries
I also have this problem and just found a solution. I am working with WIN8, and downloaded release-1600-gdal-1-8-0-mapserver-5-6-6.zip. As in the readme txt, I run the SDKShell.bat to set the environment. Then I include the jar and the four jni dlls in the java folder into my testing java project. There was always error like gdaljni.dll: Can't find dependent libraries. Then I figured out the settings in the bat may not been successfully done. I opened up the bat with an editor and found all the necessary enviroment settings and did it one by one. Then the java project worked with no problem. The settings needed are as follows:
SET PATH=%CD%\bin;%CD%\bin\proj\apps;%CD%\bin\gdal\apps;%CD%\bin\ms\apps;%PATH%
SET GDAL_DATA=%CD%\bin\gdal-data
SET GDAL_DRIVER_PATH=%CD%\bin\gdal\plugins
SET PROJ_LIB=%CD%\bin\proj\SHARE
For the PATH you can just in explorer right click on computer-properties-advanced system settings-Change enviroment variables. Add the absolute paths(%CD% means the current folder of the bat file, in my case is C:\GDAL, so path "%CD%\bin" should be changed into "C:\GDAL\bin") of "SET PATH line" to your PATH. For the other three lines of settings, just add three system variable for each and aslo change the path containing %CD% into abousolute paths. Then, everything should be ok. Note I omitted some paths in the bat file which I do not need for my java bindings. You can also add them to PATH if you want to do use gdal with other languages. I guess the most common mistake is forgetting to add the GDAL_DRIVER_PATH and PROJ_LIB.Hope it may be helpful for the others who have such issue.
If UnsatisfiedLinkError: gdaljni.dll: Can't find dependent libraries occurs...
Check the path of GDAL libraries, data and plugins (they must be in the installation path of your application)
Missing VC++2010 runtime (if GDAL is compiled using VC++2010): download the Microsoft Visual C++ 2010 Redistributable Package:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84
You may need to set following in the Windows system environment variables:
GDAL_DATA=<path to gdal-data folder>
GDAL_DRIVER=<path to your gdal\plugins folder>
This might help you:
1) set path as said above
2) Put the *jni.dll files in the 'The path where you installed gdal'\gdallib\bin\gdal\java\ directories into the jre\bin directories that you are using. (This saved me!)
Hope it will be helpful:)

Categories