After installing Android SDK, Gradle and JDR, JRE on Linux, Android Studio could not detect SDK in /usr/lib/jvm/jdk1.8.0_11.
IntelliJ IDE does not have any problem and everything is OK. But android studio displays this error:
No Android SDK found. Please configure an Android SDK.
the path of the SDK is the same as for IntlliJ IDE.
.bashrc content:
export JAVA_HOME=/usr/lib/jvm/jre-8-oracle-i586
Other Information:
sudo update-alternatives --config java
[sudo] password for tux-world:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/jre-8-oracle-i586/bin/java 317 auto mode
* 1 /usr/lib/jvm/jdk1.8.0_11/bin/java 1 manual mode
2 /usr/lib/jvm/jre-8-oracle-i586/bin/java 317 manual mode
How to resolve this problem?
Have you downloaded any SDK from Android SDK Manager? or you just installed the SDK manager?
Related
I've installed .NET 6 (version 6.0.100-rc.1.21458.32) and Visual Studio 2020 Preview (although it might be not a prerequisite).
I am trying to debug a hello-world application but I am getting a build error regarding Java.
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.100-rc.1.12\targets\Microsoft.Android.Sdk.Tooling.targets(20,5): error XA0031:
Java SDK 11.0 or above is required when using .NET 6 or higher.
I've installed Java 17 setting Path as well as pointing to the Java Development Kit Location in Visual Studio settings (tools->options->Xamarin->Android Settings). Because that didn't work I've set the JDK location to Microsoft's openjdk, but it still doesn't work.
What's wrong here?
Installing Microsoft's OpenJDK 11 did the job for me.
You may notice that Visual Studio installs a version of Microsoft
OpenJDK, however, you need to install the Microsoft OpenJDK 11
When I installed VS2022 preview 4, my configuration became C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot
This can be fixed for you if you run the maui-check command (if you installed that component during visual studio installation).
If you don't have the maui-check tool, you can get it by running the dotnet tool install -g Redth.Net.Maui.Check command
Maybe you skipped a step during installation and that's why you get the error.
For those who have the same problem in Jetbrains Rider :
Install OpenJDK 11 (Microsoft's OpenJDK 11 seems to be better) as mentioned by #themelis
Press Ctrl + Shift + A and search MSBuild global properties or go to File > Settings > Build, Execution, Deployment > Toolset and Build
Edit the MSBuild global properties and add the following property:
Name: JavaSdkDirectory
Value: {OpenJDK installation directory} (mine is C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot)
Save and Enjoy!
Visual Studio for Mac
Here's how I got it working on macOS with Visual Studio for Mac.
Install Microsoft Open JDK
On macOS, install the Microsoft Open JDK using HomeBrew:
brew install --cask microsoft-openjdk
Configure Visual Studio for Mac
In Visual Studio for Mac, select Visual Studio -> Preferences.
In the Preferences window, navigate to SDK Locations -> Android -> Locations.
In the Java SDK (JDK) Location: text box, enter the following:
/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Click OK
I have tried the answers at here & here to no avail.
After installing Android Studio & Flutter on Windows 10, when I run flutter doctor, I get the following:
[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.19043.1202], locale en-US)
[X] Android toolchain - develop for Android devices
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.60.0)
[√] Connected device (2 available)
Opening Android Studio > SDK Manager > Android SDK > SDK Tools uninstalling and re-installing Android SDK Command-line Tools (latest) has no effect.
I have also added <pathToSDK>\tools\bin, <pathToSDK>\platform-tools\, and <pathToSDK>\cmdline-tools\latest\bin to the user PATH environment variables.
Following the flutter instructions and running <pathToSDKManager> --install "cmdline-tools;latest" (Which for me is located in <pathToSDK>\cmdline-tools\latest\bin) results with:
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.
I haven't been able to find any documentation on this other than that I need to install some version on Java and add it to my path. The https://flutter.dev/docs/get-started/install/windows page mentions "Make sure that you have a version of Java 8 installed and that your JAVA_HOME environment variable is set to the JDK’s folder." and then states "Android Studio versions 2.2 and higher come with a JDK, so this should already be done." but doesn't elaborate further.
Opening Android Studio and going to File > Project Structure > Project > Project SDK I can see that Android Studio already recognized several versions of Java installed:
You can follow the below steps in order to ensure proper working of your flutter project:
Your sdk manager should look something like this:
1. Installing Android SDK Command-line Tools in Android Studio:
Preferences > Appearance & Behavior > System Settings > Android SDK > SDK Tools >
Install these 3 tools:
Android SDK Command-line Tools (latest)
Android SDK Build Tools 31
Android SDK Platform tools (latest version 31)
Make sure every tool is the same latest version in order to avoid any errors as there might be new updates later on.
Also make sure to Accept Android Licences by running below command in your cmd:
flutter doctor --android-licenses
If anything above didn't work out make sure you have set the proper JDK/JRE locations in environment variables in system settings of windows:
Add below path in your System environment path variable for user variable as well as your system variable:
C:\Program Files\Java\jdkXXXXX\bin
Here, XXX is your version, and this should be added in your sys var and user both
C:\Users\Neha\AppData\Local\Android\Sdk\tools
C:\Users\Neha\AppData\Local\Android\Sdk\build-tools
C:\Users\Neha\AppData\Local\Android\Sdk\platform-tools
The above three paths should be added in your user variable path. Check the two screenshots attached below for proper path settings.
I have added android studio's tools path also so do that as I have done in screenshot.
This one is for user variable path:
This one is for system variable path:
Follow source to learn more about setting the path for java.
Just Install them:
Android SDK Command-line Tools (latest)
Android SDK Build Tools 31
Android SDK Platform tools (latest version 31)
run: 'flutter doctor --android-licenses'
after run 'flutter doctor' again.
And boom. it will work.
In the screen you've shown, just use "Android Studio default JDK" (or any other JDK 11).
Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK.
You'd also need to setup the same path as JAVA_HOME environmental variable, as well as ANDROID_HOME. In Windows, these can be added below Settings > Advanced System Settings > Environmental Variables. Flutter needs these set up to find the CLI tools ...
and the problem might not be the CLI tools themselves, but that it doesn't know about the Java SDK or Android SDK at all.
If you are installing Flutter without Android Studio.
Run this command in your Android/bin folder directory where you have your sdkmanager.bat file.
In my case its C:\Android\bin>.
type this command
sdkmanager.bat --install "cmdline-tools;latest --sdk_root=../
This worked for me and I hope it will work for you too.
If you have installed Flutter without Android Studio. Run this command in your Android/bin folder directory where you have your sdkmanager.bat file. In my case its C:\Android\bin>
sdkmanager.bat "cmdline-tools;latest" --sdk_root=../
I couldn't run the flutter app on android emulator or android phone. I installed the recently released android studio for arm-mac platform on m1 mac. Please answer if I am doing anything wrong here or is it the problem with the release itself.
Debug console output:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Exception: Gradle task assembleDebug failed with exit code 1
flutter doctor -v output :
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-arm, locale en-IN)
• Flutter version 2.2.1 at /Users/hmnth/FlutterDev/flutter
• Framework revision 02c026b03c (10 weeks ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/hmnth/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /usr/bin/java
✗ Could not determine java version
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[!] Android Studio
• Android Studio at Applications/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Android Studio not found at Applications/Contents
• Try updating or re-installing Android Studio.
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.107
! Doctor found issues in 3 categories.
Go to Applications then right click on Android Studio, then choose "Show Package Contents", create a new folder inside jre named jdk and copy the contents of jre to jdk
This is the link for the fix https://github.com/flutter/flutter/issues/76215#issuecomment-864407892
In 2023.
Go to Applications -> right click on Android Studio -> choose "Show Package Contents".
I have only folder .jbr (not have .jre). So, I create new folder with name .jre and copy folder "Contents" (from .jbr) -> paste to .jre folder.
Open terminal and run: flutter doctor -v
That works for me.
I encountered this issue because I didn't have Java installed. If you can't see a Java icon under System Preferences, Java 7 or later versions is not installed. Link to java.com
I was able to fix my issues by doing the following, I sync my project with Gradle files
I downloaded Java 8 (but I don't think this guy did the work)
2022
First of all, check out did you install Java on your mac.
After that I suggest to install Java 19.
If you finish this step
on command pannel : nano .zshrc
add the below code to the bottom of file;
echo 'export JAVA_HOME="$(/usr/libexec/java_home)"' >> ~/.zprofile
echo 'export PATH="$HOME/.daml/bin:$PATH"' >> ~/.zprofile
That is all.
You are good to go.
I am getting the following error when trying to install Android Studio 3.1 Preview 2 on Windows:
Error: CreateProcess error=216, This version of %1 is not compatible
with the version of Windows you're running. Check your computer's
system information and then contact the software publisher.
I have tried to install the following - but still didn't help:
Install jdk1.8.
I also tried the following in Android Studio:
File->Project Structure->SDK Location (select your directory where the JDK is located, by default Studio uses embedded JDK) -> Click OK
But for some reason this produces error=216.
Android Studio is giving me a Gradle build error that looks like this:
Error:(3, 22) compileSdkVersion android-22 requires compiling with JDK 7
Now it gives me these clickable prompts:
Download JDK 7
Select a JDK from the File System
Open build.gradle File
And I have already downloaded and installed JDK 7. The problem is when I go to select it in the "File System" i can only find a directory named 1.6.0 JDK. Furthermore, the installation of JDK 7 skipped the bullet point where I would've selected the install directory, so I'm really not sure where it is. My java control panel says I have "Java 7 Update 79" so I'm pretty sure I'm close, I just need to tell android studio where it is. I also ran the java -version command in the terminal and it says my version is "1.7.0_79".
Any help would be appreciated!
You can use cmd + ; for Mac or Ctrl + Alt + Shift + S for Windows/Linux to pull up the Project Structure dialog. In there, you can set the JDK location as well as the Android SDK location.
To get your JDK location, run /usr/libexec/java_home -v 11 in terminal. Send 1.7 for Java 7, 1.8 for Java 8, or 11 for Java 11.
Android Studio Arctic Fox (2020.3.1)
In Android Studio Arctic Fox (2020.3.1 Patch 4), the JDK Location setting is moved to:
File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK
Up to Android Studio 4.2
You can follow the answer from Ben Kane, the JDK Location setting is located in:
File > Project Structure > SDK Location
For new Android Studio versions, go to C:\Program Files\Android\Android Studio\jre\bin(or to location of Android Studio installed files) and open command window at this location and type in following command in command prompt:-
java -version
The gradle sync uses the following JDK location:
In Android Studio, File -> Project Structure
Navigate to the SDK Location.
cd /Applications/Android\ Studio\ 4.1.0.app/Contents/jre/jdk/Contents/Home
➜ Home ./bin/java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
OpenJDK 64-Bit Server VM (build 11.0.8+10-b944.6916264, mixed mode)
On a Mac, you can use terminal to go to /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home (or wherever your Android SDK is installed) and enter the following in the command prompt:
./java -version
In Android Studio 4.0.1, Help -> About shows the details of the Java version used by the studio, in my case:
Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 25, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 8
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: com.google.services.firebase
This is old question but still my answer may help someone
For checking Java version in android studio version ,
simply open Terminal of Android Studio and type
java -version
This will display java version installed in android studio
gradle.properties:org.gradle.java.home=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
./gradlew assembleDebug -Dorg.gradle.java.home=/Applications/Android\ Studio.app/Contents/jre/Contents/Home