Unable to locate the Android SDK - android

I already had Android Studio and the Android SDK installed. I later added Flutter and the Flutter SDK. Here is my problem: When I run
flutter doctor
It shows,
that I do not have the Android SDK installed.

You can configure the Android SDK for your project using
flutter config --android-sdk /path/to/android/sdk
The PATH variable also should contain the SDK, like
export PATH=$PATH:/usr/local/opt/android-sdk/emulator:/usr/local/opt/android-sdk/build-tools/26.0.1:/usr/local/opt/android-sdk/platform-tools:/usr/local/opt/android-sdk/tools
/usr/local/opt/android-sdk and 26.0.1 might not match your system. That's just an example.

Step-by-step guidance for Windows with pictures
Step 1.
If you see this error, it means Flutter does not locate your Android SDK.
There are two folders containing all files of the "Android SDK". They are "Platform" and "Platform Tools":
Those folders are located in my computer here:
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk
(My name is Zohaib Saleem, and you should replace my username folder name with your computer username.)
Step 2
Type "Env" in the search bar of Windows
Click on "System Variable Environment"
Click on "Advanced and Environment Variable"
Go to System Variable → Path → Edit:
Now paste the path of both folder "platform" and "platform-tools", respectively.
In my case, the paths are:
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk\platforms
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk\platform-tools
After adding the path to your System variable it looks like:
Click OK
Restart PowerShell and again run the command "flutter doctor".
Now, the Android SDK problem is resolved, but you faced another problem:
To resolve this issue, just run the command
flutter doctor --android-licenses
And accept all with "Y". At the end, after typing multiple 'Y's, again run 'flutter doctor' and all is set!

flutter config --android-sdk /your path
example
flutter config --android-sdk /root/Android/Sdk
Tools > SDK Manager > Android SDK
images

Locate the Android SDK folder (e.g., D:\SDK).
Add platforms (D:\SDK\platforms) and platform-tools (D:\SDK\platform-tools) to the PATH variable.
Run flutter doctor. It should not show any errors or warnings.

For this issue you have to add three variables to the Path in the:
C:\Users\admin\AppData\Local\Android\platforms // The path to
platform
C:\Users\admin\AppData\Local\Android\platform-tools //
The path to platform-tool
C:\Users\Admin\AppData\Local\Android\emulator // The path to
emulator

Related

Android Sdk manager not found- Flutter doctor error

I installed flutter and it was working fine but after updating it to recent version, flutter is not able to find the android sdk manager. I've tried running flutter doctor and tried to install android licenses but the error "Android Sdkmanager not found is shown". I've attached the image of my command prompt here.
Here's what I've already tried but didn't worked...
I had cmd tools installed in my android studio, so I uninstalled and reinstalled it.
Changed path settings, added my sdk path to environment variables.
Also added cmd tool path to system variables.
Deleting the cmd tools and downloading it from android studio official site and pasting it into the sdk manager folder.
Changing the sdk path to the sdk manager folder path in command prompt.
Running command prompt as administrator.
I've attached the image of command prompt with 'flutter doctor -v' here
I've tried almost everything I found on google but nothing seems to solve my problem. I don't know what should I do next and I'm stuck in it from two days.
Here's the flutter doctor --android-licenses -v image
Please help, Thanks.
First, make sure to follow the official documentation step by step to install and set up Android SDK for Windows (Maybe uninstall first everything from before to remove any kind of conflict that exist). Also, don't install the Command line tools only and include it to PATH (Remove every related Android SDK PATH or even other environment variables that are still there too). The recommended way is inside the Android Studio in Preferences -> Appearance & Behavior -> System Settings -> Android SDK -> SDK Tools and select Android SDK Command-line Tools.
Second, make sure you restart the command prompt for the changes to take effect. For example, changing PATH doesn't update the running processes. So, just restart the ones that need the new configurations. Sometimes even restart the entire system so every process has the updated configurations.
And then try again to accept the licenses:
flutter doctor --android-licenses
I found the solution to my problem stated above, the android sdkmanager.bat file was getting deleted automatically by an antivirus named "SAntivirus". I uninstalled the file from my program files and it worked. Now my flutter doctor is working fine and accepted all the licenses. Thank you all for your support.
you should install the android sdk command line tools in sdk tools on your android studio ( uncheck the hid obselute pacakges ).

Not able to setup React native project on windows

Hi I have followed the official documentation for setting up the React native project on windows.
I have added the ANDROID_HOME variable as system variable at location
"C:\Users\AKSHAY\AppData\Local\Android\Sdk"
In the second step I was supposed to add Environment variable at
"C:\Android\tools\bin\platform-tools"
but there is no tools folder in Android instead I found platform-tools under SDK below is the location
"C:\Users\AKSHAY\AppData\Local\Android\Sdk\platform-tools"
Now when I am running
npx react-native run android
I am getting the below attached error
Here is the SDK folder
Please help.
setup an android emulator first with avd
if your RN >=.62
You can run npx react-native doctor inside your project folder
else
run npx #react-native-community/cli doctor inside your project folder
This command checks your environment and displays a report of the status of react native installation. Check the output carefully for other software you might need to install.
You can install android studio then add ANDROID_HOME to your ENV Variable and point to your SDK.
Follow this link: https://web.archive.org/web/20180210044548/http://spring.io/guides/gs/android/
The path you are looking for is located at :
C:\Users\"yourUser"\AppData\Local\Android\Sdk\platform-tools

Sdkmanager "Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli" on Windows

I am trying to install Flutter without Android Studio and here is what I did:
Installed Java 8
Installed and Unzipped Flutter SDK to C:\src.
Installed and Unzipped Android Command-line tools (sdkmanager) to C:\Android.
Added the environment variables (ANDROID_HOME: C:\Android)
Now when I try to run sdkmanager to install Android SDK, I get this error:
"Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli"
I have tried reinstalling Flutter sdk and the sdkmanager with no luck.
Here is Flutter Doctor's output:
sdkmanager error:
Open the sdkmanager.bat in a text editor and add echo %CLASSPATH% just below the CLASSPATH=%APP_HOME%\...\sdkmanager-classpath.jar. Then run sdkmanager --help which will echo the CLASSPATH of the required file. And check whether is it the valid path.
In my case, it was the wrong path,
It said my sdkmanger-classpath.jar is in lib folder. But it was not! It was actually inside the lib/_ folder. So as the simple solution what I did was copy the content in side lib/_ folder to lib. Then it worked fine!
Download the SDK tools ZIP (Under Command Line Tools in https://developer.android.com/studio).
Unzip using 7zip. Avoid using the default windows extractor - that doesn't do the extraction correctly.
After unzipping using 7zip, place the contents into the sdk folder (C:\Users\<username>\AppData\Local\Android\Sdk\tools\bin and C:\Users\<username>\AppData\Local\Android\Sdk\lib) and run sdkmanager on command prompt.
On Windows Server 2019, using commandlinetools-win-6609375_latest.zip, we faced the same issue. We placed package inside Program File (i.e. C:\Program Files\Android\cmdline-tools\tools\bin).
It seems this will not work if there is space in the path. So we placed it in folder path without spaces (i.e. C:\Android\cmdline-tools\tools\bin) and it is working fine!🎉
As #Chrishan wrote Avoid using default windows extractor.
You can use the PowerShell:
Expand-Archive commandlinetools....zip C:\Android\Sdk
It worked for me.
Make sure there exists no space in the path folders in the path to SDK.
example: C:\Users\Anu Jadav\xyz\
like above in username I had space, Initially, I was not able to execute flutter doctor --android-licenses.
After I renamed the username. Then it worked like a charm.
I renamed my username using this reference video
.
Go to android sdk folder.
Open cmdline-tools folder.
Then rename "latest" folder as "tools".
Default name:
(Path to sdk)\AndroidSDK\cmdline-tools\latest
After rename:
(Path to sdk)\AndroidSDK\cmdline-tools\tools
Then;
run flutter doctor command using terminal.
I fixed by adding '--sdkroot ' pointing to the root folder (i.e. parent of bin).
e.g. % ./bin/sdkamanager --sdkroot .
I have solved this issue by doing so many things.
Download Java 8.
Set EV to the Java 8 folder.
Download SDK in separate folder.
While setting EV of SDK make it sure there is no whitespace in the path.
Set path of the following in user variables:
Build-tools.
platform-tools.
platform
Now enter flutter doctor --android-licenses
press y multiple times and at last your licenses will be accepted.
Check whether your license accepted or not by using flutter doctor
Firstly open android studio and from there open sdk manager and install required sdk tools then -
Make sure there exist no space in the path folders in the path to sdk.
Add ANDROID_SDK_ROOT variable to the Users variable with value as the path for sdk folder e.g. C:\users\xyz\android\sdk (there should be no space in these folder names).
Add this path to the path variable in the system variable.
Run flutter doctor in the command prompt.
Run flutter doctor --android-licenses.
Accept the licenses by entering 'y'.
--The setup should be done and just check by running flutter doctor.
I fixed this issue by removing a space in my path where i had extracted the cmd tools.
My path was:
C:\Cordova Tools\cmdline-tools
there was a space in folder name "Cordova Tools".
I removed the space and changed folder name like:
C:\Cordova_Tools\cmdline-tools
And it worked just perfectly.
The problem may be due to the fact that your sdk installation failed severally before finally installing.
To check if that is the case, go the path C:\Users<username>\AppData\Local\Android\Sdk and if there are tools, tools-1, ...
The necessary files are installed in the last of this folder.
So, rename the supposed original folder - tools, to something else and change the name of the one in which the installation is done to tools.
This should solve the problem.
download jdk 11
and update ev JAVA_HOME to C:\Program Files\Java\jdk-11.0.17

How to fix 'Android SDK not found at this location' error while installing flutter?

I'm installing flutter in my Ubuntu 18.10. I'll be using Visual Studio Code for flutter development. I've not installed Android Studio.
I've downloaded Android Command line tools from official android site and extracted it in a separate folder in Documents/development/android
I set the path for ANDROID_HOME in the bashrc file by following the flutter documentation
Here is the .bashrc file
And the Android toolchain error
It seems that , you set the ANDROID_HOME variable but it is not added to PATH.
Make sure you add the ANDROID_HOME to the path as below
export PATH=$PATH:$ANDROID_HOME/bin
and re-launch the console.
update
In order for Android SDK to work fine, you need to set path for the below SDK packages.
..android-sdk\tools
..android-sdk\platform-tools
and your ANDROID_HOME will be
..android-sdk
I am not sure what you are referring to when you are saying that you have downloaded Android Command Line tools. From the output in your terminal, it tells me that you do not have the SDK files in your machine. To download the Android SDK, please see this link here and download the tar file that matches your operating system. Then extract the tar file in the folder which you have set as ANDROID_HOME. This should work fine.
In case you are having the same error, I strongly recommend downloading the Android Studio and install the Android SDK through the Android Studio. The flutter documentation says so as well. You can always uninstall or remove Android Studio after it is being installed and if you are not considering using it.
please replace yout android sdk in thatway this is default installation location of sdk C:\Users\Intel\AppData\Local\android\android_sdk

React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH

I've followed step by step the official Getting Started. I started from a clean linux install and installed everything required as per the "Building Projects with Native Code" tab. I have also read the troubleshooting section. I've already created the project using the terminal.
This is the error when I run react-native run-android:
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew 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.
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
It does not find JAVA_HOME because the latest versions of Android Studio don't require Java to be installed in the system. Instead an internal JRE is used.
Duplicate disclaimer: I've already read this question. This is not what I want. I know how to set the Java home. I just want to run the react project WITHOUT having to install a separate Java.
Questions:
How could I find the internal Java inside the Android Studio folder so that I could point JAVA_HOME to it?
If not possible, could I open and run the project inside the android folder with Android Studio? How would I refresh this project after modifying the React JavaScript code in the parent folder?
Windows 10:
Android Studio -> File -> Other Settings -> Default Project Structure... -> JDK location:
copy string is shown, such as:
C:\Program Files\Android\Android Studio\jre
In the file locator directory window, right-click on "This PC" ->
Properties -> Advanced System Settings -> Environment Variables... -> System Variables
click on the New... button under System Variables, then type and paste respectively:
.......Variable name: JAVA_HOME
.......Variable value: C:\Program Files\Android\Android Studio\jre
and hit the OK buttons to close out.
Some installations may also require JRE_HOME to be set in the same way.
To check, open a NEW black console window, then type echo %JAVA_HOME%. You should get back the full path you typed into the system variable. Windows 10 supports spaces in the filename paths for system variables very well and does not need ~tilde eliding.
I'll answer my own questions and sponfeed my fellow linux users:
1- To point JAVA_HOME to the JRE included with Android Studio first locate the Android Studio installation folder, then find the /jre directory. That directory's full path is what you need to set JAVA_PATH to (thanks to #TentenPonce for his answer).
On linux, you can set JAVA_HOME by adding this line to your .bashrc or .bash_profile files:
export JAVA_HOME=<Your Android Studio path here>/jre
This file (one or the other) is the same as the one you added ANDROID_HOME to if you were following the React Native Getting Started for Linux. Both are hidden by default and can be found in your home directory. After adding the line you need to reload the terminal so that it can pick up the new environment variable. So type:
source $HOME/.bash_profile
or
source $HOME/.bashrc
and now you can run react-native run-android in that same terminal. Another option is to restart the OS. Other terminals might work differently.
NOTE: for the project to actually run, you need to start an Android emulator in advance, or have a real device connected. The easiest way is to open an already existing Android Studio project and launch the emulator from there, then close Android Studio.
2- Since what react-native run-android appears to do is just this:
cd android && ./gradlew installDebug
You can actually open the nested android project with Android Studio and run it manually. JS changes can be reloaded if you enable live reload in the emulator. Type CTRL + M (CMD + M on MacOS) and select the "Enable live reload" option in the menu that appears (Kudos to #BKO for his answer)
I think the right way to find the internal Java used by the Android Studio is to
Open Android Studio
Go to File->Other Settings->Default Project Structure/JDK Location:
and copy what ever string is specified there
This will not require memorising the folder or searching for java and also these steps wil take of any future changes to the java location by the Android Studio team changes I suppose
I'm using Ubuntu 20 on my machine, I have got the same problem the thing that worked for me was:
sudo apt-get install default-jre
you can verify that if the installation was successful or not by:
java --version
you are gonna see something like this in your terminal
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-Ubuntu-0ubuntu3)
OpenJDK 64-Bit Server VM (build 11.0.12+7-Ubuntu-0ubuntu3, mixed mode, sharing)
It is located on the Android Studio folder itself, on where you installed it.
Please add the JAVA_HOME in the System variable no in the user variable
Create the Variable name as JAVA_HOME
Please use these format in the value box --> C:\Program Files\Java\jdk(version) what you have or downloaded.
I fixed this issue by installing jre, I have jdk already installed but jre was not installed.
For those still not able to set JAVA_HOME from Android Studio installation, for me the path was actually not in C:\...\Android Studio\jre
but rather in the ...\Android Studio\jre\jre.
Don't ask me why though.
Environment variables jre location snippet
For ubuntu 16.0+
You can find the jre folder in android studio on this path /snap/android-studio/current/android-studio/jre
add the following line in your .bashrc or .bash_profile
export JAVA_HOME=/snap/android-studio/current/android-studio/jre
type
sudo nano $HOME/.bashrc
or
sudo nano $HOME/.bash_profile
after this execute the following line to in your terminal where you are executing the npx react-native run-android to reload the terminal with the new changes
source $HOME/.bashrc
or
source $HOME/.bash_profile
All I did is go to my project directory from the cmd (command prompt) I typed java -version.it told me what version it was looking for. so I Installed that version and I changed the path to were the jdk of that version was located .
apparently the system variables were not in sync with the user
variables
run as admin on command prompt and set the variable
i also saw some tips to close the node window and the vscode terminal for
the variable to take effect
tip from this site
https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
setx -m JAVA_HOME "C:\Progra~1\Java\jdk1.8.0_XX"
and then
echo %JAVA_HOME%
For fish users:
Open ~/.config/fish/config.fish;
Include line set JAVA_HOME /home/ronald/Documents/android-studio/jre and set PATH $PATH $JAVA_HOME;
Re-open fish terminal.
Welcome :)
After adding the environmental variable , please restart the editor. It may save your ton of time.
Make sure you have java installed
your path is wrong
do this:
export | grep JAVA
THE RESULT: what java home is set to
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
follow the path to see if the directories are correct
i did this in my terminal:
open /Library
then i went to /Java/JavaVirturalMachines
turns out I had the wrong "jdk1.8.0_202.jdk" folder, there was another number...
4. you can use this command to set java_home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
I ran this in the command prompt(have windows 7 os):
JAVA_HOME=C:\Program Files\Android\Android Studio\jre
where what its = to is the path to that jre folder, so anyone's can be different.
what I did to solve this on windows was to go to the environment variables and set the variable name to JAVA_HOME and then set the variable value to C:\Program Files\OpenJDK\openjdk-8u312-b07
then I set the path to C:\Program Files\OpenJDK\openjdk-8u312-b07\bin
From Android Studio, go to File, Settings, "Build, Execution, Deployment", Build Tools, Gradle. You should see the path to your JDK there, as visible in the screenshot (tested on Android Studio version 2020.3.1). Set an environment variable called JAVA_HOME containing that path (just google "set an environment variable" and followed by your Operating System name).
for those who are new to react native development
please set JAVA_HOME like this
instead of
C:\Program Files\Java\jdk1.8.0_301\bin
just remove "\bin" from path
C:\Program Files\Java\jdk1.8.0_301 after removing \bin
Guys after fight a lot to find the solution, including pass for many of that articles. I just realized that when you extract the Android SDK it doesn't come inside the folder cmdline-tools/latest and doesn't matter the place that I put the folder, opt/Androd_SDK, $HOME/Android_SDK the sequence of the error were the same. Until I got this error running:
➜ bin ./sdkmanager -version
Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: /cmdline-tools/latest/
So, basic the solution was add the content of the SDK zip inside of the folders cmdline-tools/latest.
Once you do this, SDK and all the commands will work normally. Just don't forget to finish the configuration, like create the environment of the Android SDK, JAVA and so on.
An awesome article is that one:
https://medium.com/#khairold/setting-up-react-native-on-linux-without-android-studio-a65f3e011bbb
;)
if someone still facing similar issue and looking for an answer for the same? I would like to share the solution which worked for me. And by the way I haven't installed JAVA JDK/SDK in order to resolve the issue.
I am using Visual Studio code to develop react-native apps (using nox player for android app testing), I ran into the similar issue:
Issue:
$
› Building app...
$
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.
C:\Users...\android\gradlew.bat exited with non-zero code: 1
Resolution: In package.json file I have changed "main": "index.js" to "main": "node_modules/expo/AppEntry.js" it worked for me.
It would be great if this solution helps anyone, let me know for any additional information.
Make sure you have installed the following:
Java
JDK
JRE
If you use Ubuntu, maybe its helpful this tutorial. You have solution for how to solve error ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH..
There are many solutions found for Windows or Mac OS on internet to resolve this error. I'm using Ubuntu 22.10 kinetic
Solution:
Go to your Android Studio folder, find folder named jbr, copy all content folder, and if you don't have, create a folder named jre and copy in jre folder, all contents from jbr folder. Case close. Error solved.
java is not set
Video

Categories

Resources