Unable to find bundled Java version. Android Studio, [duplicate] - flutter

This question already has answers here:
Missing bundled JRE in Android Studio for Flutter
(2 answers)
Closed 21 days ago.
Unable to find bundled Java version in flutter new version of Android Studio(Electric Eel) in Windows.
Android Studio Electric Eel Unable to find bundled Java version.

For Windows:-
Go to C:\Program Files\Android\Android Studio\jbr and copy the content
Copy the content and paste it to the C:\Program Files\Android\Android Studio\jre

Related

Flutter not able find visual studio toolchain

I have been trying to do flutter doctor but its unable to find the visual studio toolchain
This is what did
Install Flutter 2.2.0 version
Install visual studio proffesional 2019 with desktop c++ component ( did few uninstall and install just to ensure its not corrupted)
Replace the vswhere.exe with 3.1.1 and 3.0.3 version
List item
Change jdk to 1.8
Enable windows desktop via flutter config
I realized when i do flutter doctor -v the vshwere.exe just keep poping up and close 2 3 times it seems trying to locate something

when run the Flutter doctor command why it shows "Unable to find bundled Java version." and how to solve that

Android Studio (version 2022.1) X Unable to find bundled Java version.
Go to C:\Program Files\Android\Android Studio then copy all the content of jbr and paste all that content into the jre folder.
Run flutter doctor again
I tried this one and it worked for me
C:\Program Files\Android\Android Studio
then copy the content of jbr and paste the content into the jre folder
run doctor again and problem solved

Android Electric eel Mac M1: Unable to find bundled java version when running flutter doctor -v

I am having problems with android studio upon updating to electric eel. This was not a problem before update. I have a Mac M1 and flutter version is Flutter 3.3.10 β€’ channel stable
When Running flutter doctor -v I get this for the android studio section:
Android Studio (version 2022.1)
β€’ 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.
How do I resolve this issue?
For Windows Users
Step - 1
Install Java JRE (JAVA RUNTIME ENVIRONMENT)
Link
https://www.java.com/en/download/manual.jsp
After downloading Click on Install and Change Installation folder any folder you like
Step - 2
Copy all of this content and GO TO Android Studio Installation Path
for-example
C:\Program Files\Android\Android Studio\jre
By default Android Studio has a folder called JRE
go inside jre folder and paste everything
If JRE folder in Android Studio has anything inside please delete it before pasting.
Congratulations Windows User
I was struggling with this for like two days and I search it on YouTube and found nothing everything was one year old so I end up Julia Pak Channel while she had Mac but I got the idea to find a solution for windows (basically copy-pasting idea) and find a link in her description and I saw her content and she does an amazing job to help people
So Major Thanks to her.
If anyone ends up on her beautiful YouTube Channel
Give her a like and Subscribe to show some LOVE
YouTube:- https://www.youtube.com/#Juliapak
Thanks.
As you can see Unable to find bundled Java version. is the problem when running flutter doctor -v after updating.
This is the work around I did in terminal:
cd /Applications/Android\ Studio.app/Contents/jbr
ln -s ../jbr jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Then I did this in finder:
locate Android Studio
right click on Android Studio and click `show package contents'
create a new folder and call it jre
You'll see a jbr folder, open it and copy its contents
paste those contents into the jre folder you created. File structure looks like this now
Honestly I think this is creating redundancy of some sort, but hey it works!πŸŽ‰πŸŽ‰ when I run flutter doctor -v I now get this for android studio.
[βœ“] Android Studio (version 2022.1)
β€’ 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
β€’ Java version OpenJDK Runtime Environment (build
11.0.15+0-b2043.56-8887301)
I'm sure there are better work arounds but this works for me.πŸ₯³πŸ₯³πŸ₯³
link to video showing how I solved this
For mac users, just go to where is your android studio installed
if you install android studio using the installer use
cd /Applications/Android\ Studio.app/Contents
if using JetBrains toolbox use
cd "/Users/ahmedhnewa/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents"
you can go to the settings of the ide and find where it's installed
then just type
open .
so it will be opened in finder
copy the folder jbr and rename it to jre
I think the flutter team should look into this so the flutter command line
can know where the bundled JDK is in the new android studio update.
currently, there is no any recent update to the flutter tool but after it get update the issue should be fixed without copy the jbr folder and rename the copied one to jre
Edit
For Linux it's almost the same, just the path of android studio is different, it's depend on where and how did you installed it, for Windows users
just right click on the android studio in the desktop and open file location and
do the exists same thing on all platforms
This solution worked for me on my Mac
Navigate to Applications on finder Right Click Android Studio. Select "Show package contents". And then right-click "Contents" and select "New Terminal at Folder". Finally copy and paste this line and press enter.
ln -s jbr jre
Thank you so much! After upgrading to Android Studio Electric Eel when I check flutter doctor I came across with "unable to find bundled java version" then I saw that and that helped a lot! Thanks for your effort.
Simple Guide
There is problem with Electric eel
Android Studio App contents after installation is not having jre dir
On Mac What i did:
copy the jbr directory available and name it as jre
jre directory with contents will resolve this

Update Gradle in Flutter project

I have this project in Flutter, but I haven't been able to build an apk for a couple of weeks, because of the Gradle version. I've tried everything, but Flutter always returns the error below:
I already install every update I found, even though, it shows that the Gradle version is 4.10.2.
flutter build apk
...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\israel.gomes\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\audioplayers-0.17.4\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'audioplayers'.
> Failed to apply plugin [id 'kotlin-android']
> The current Gradle version 4.10.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 5.3 or newer, or the previous version of the Kotlin plugin.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
The plugin audioplayers could not be built due to the issue above.
Here some information about the project status and environment----------------------
Already changed gradle-wrapper.properties (Current file):
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
android/build.gradle(Current file):
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
.
.
.
gradle --version
------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------
Build time: 2019-09-05 16:13:54 UTC
Revision: 55a5e53d855db8fc7b0e494412fc624051a8e781
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 1.8.0_261 (Oracle Corporation 25.261-b12)
OS: Windows 10 10.0 amd64
flutter doctor -v
[√] Flutter (Channel dev, 2.1.0-12.1.pre, on Microsoft Windows [versão 10.0.19042.867], locale pt-BR)
β€’ Flutter version 2.1.0-12.1.pre at C:\Flutter
β€’ Framework revision 8264cb3e8a (3 weeks ago), 2021-03-10 12:37:57 -0800
β€’ Engine revision 711ab3fda0
β€’ Dart version 2.13.0 (build 2.13.0-116.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
β€’ Android SDK at C:\Users\israel.gomes\AppData\Local\Android\Sdk
β€’ Platform android-30, build-tools 30.0.2
β€’ ANDROID_HOME = C:\Users\israel.gomes\AppData\Local\Android\Sdk
β€’ Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
β€’ All Android licenses accepted.
[√] Chrome - develop for the web
β€’ Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
β€’ Android Studio at C:\Program Files\Android\Android Studio
β€’ 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
β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] IntelliJ IDEA Community Edition (version 2020.3)
β€’ IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3
β€’ Flutter plugin version 55.0.4
β€’ Dart plugin version 203.7759
[√] VS Code (version 1.54.3)
β€’ VS Code at C:\Users\israel.gomes\AppData\Local\Programs\Microsoft VS Code
β€’ Flutter extension version 3.20.0
[√] Connected device (3 available)
β€’ Android SDK built for x86 (mobile) β€’ emulator-5554 β€’ android-x86 β€’ Android 7.1.1 (API 25) (emulator)
β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 89.0.4389.114
β€’ Edge (web) β€’ edge β€’ web-javascript β€’ Microsoft Edge 87.0.664.75
β€’ No issues found!
Here is how I upgraded gradle in my older Flutter project:
Create a new temp project with the latest version of Flutter. You'll use this to see what version of gradle Flutter is using nowadays.
In the temp project open android/build.gradle check the classpath version of gradle being used and update that in your old Flutter project. For me today it looks like this:
classpath 'com.android.tools.build:gradle:4.1.0'
In the temp project open android/gradle/wrapper/gradle-wrapper.properties and check the distributionUrl. Update your old project to use the same one. For me today it looks like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Rerun your app. It has to download the new version of gradle to the android/.gradle directory so the first time might take a while.
The easiest way (I do so as Android Dev):
Right click android folder in root folder
Flutter
Open in Android Studio
Wait for it to load completely
It'll ask you "Would you like to upgrade gradle?|"
Click Yes
flutter clean
android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
android/build.gradle:
classpath "com.android.tools.build:gradle:7.0.1"
in android/gradle.properties, add this:
org.gradle.java.home=C:\\Program Files\\Android\\Android Studio\\jre
It appears as if audioplayers has an incompatible gradle version with your project.
Try upgrading audioplayers to the newest version, although this may not fix the issue, as the last comment in this thread was less than 24 hours ago.
audioplayers: ^0.18.3
An update for 2022, Android Studio Dolphin. The other answers gave me a start, but are no longer up-to-date.
Open the main flutter project in Android Studio
Right click on the [android] module. Choose "Flutter". Choose Open Android module in Android Studio
I opened in a new window, but this probably isn't required.
As it says in the text here , choose on the menu (you must be in the "Android" project)
File
Project Structure
Project
Click the Android Gradle Plugin Version dropdown and choose the latest version (or whatever one you want to update to)
Click the Gradle Version dropdown and choose the latest version (or whatever one you want to update to)
Give time for your Gradle to sync (it might have to download quite a lot, so be patient)
Now you should be able to close the Android project window, and go back to the flutter project
Try renaming the android/ folder in your project. Then run flutter create . in the directory. This should recreate your android directory. Try your build again and see if it fixed your problem.
Upgrade gradle in a Flutter project.
Open the file gradle-wrapper.properties located at {yourProjectName}/android/gradle/wrapper/gradle-wrapper.properties and replace the distributionUrl by changing the gradle version.
For example if you want to upgrade gradle from version 5.1.1 to 6.1.1, change the Url from https\://services.gradle.org/distributions/gradle-5.1.1-all.zip to https\://services.gradle.org/distributions/gradle-6.1.1-all.zip and rebuild your app.
Fast way of doing it:
Open AndroidManifest.xml (andriod/app/src/main/AndroidManifest.xml)
Click "Open for Editing in Android Studio"
In late 2022, Android Studio can fix that and upgrade Gradle:
Open the main flutter project in Android Studio
Right click on the android module. Choose "Flutter". Choose Open Android module in Android Studio, I opened in a new window
Then, in the lower right corner, Android Studio presents a message suggesting to upgrade Gradle. Follow this suggestion!
After that, you can close the Android project window
Based on Nick Fortescue answer
I was getting this issue:
FAILURE: Build failed with an exception.
Where:
Build file '/home/marcelo-cesar/Desktop/Overseasconnection-player-teams/android/app/build.gradle' line: 47
What went wrong:
A problem occurred evaluating project ':app'.
Could not find method minSdkVersion() for arguments [19, null] on DefaultConfig$AgpDecorated_Decorated{name=main, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.ls.overseasagent, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={applicationName=android.app.Application}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig$AgpDecorated.
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 3s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I solved it by making these changes:
In android/build.gradle
update these lines with these following:
ext.kotlin_version = '1.7.10'
classpath 'com.android.tools.build:gradle:7.3.1'
In android/app/build.gradle
update with this value:
compileSdkVersion 33
defaultConfig {
…
minSdkVersion 21
targetSdkVersion 31
}
In android/gradle/wrapper/gradle-wrapper.properties
update distribution line with this:
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip

Flutter with VS Code, Unable to locate Android Studio executable

I re-installed Flutter and Android Studio.
I have already installed Java and SDK libraries and I can run the application from VS Code.
But when I tried to open Android module in Android Studio I am getting:
Unable to locate Android Studio executable
if you are on mac the put this in :
flutter config --android-studio-dir "/Applications/Android Studio.app/Contents"
The Flutter extension locates Android Studio by calling flutter config --machine. It looks like Flutter isn't returning an Android Studio path there, so you could run:
flutter config android-studio-dir /path/to/android/studio
And then Flutter should remember it, and provide it to the VS Code extension when it looks.
Simple go to C:\Program Files\Android\Android Studio\jbr
folder and copy all Folder with files
then paste it on C:\Program Files\Android\Android Studio\jre folder
And Restart your PC.
Hope your Problem is gone.
Thank you