I'm setting up Flutter for the first time and came across this error. I was told to find the java_home variable somewhere in a java folder but running automatic scans and manually searching has come up empty-handed. Do I have to download something external or is it just very hard to find? Any help is appreciated.
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
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.
Exception: Gradle task assembleDebug failed with exit code 1
I think this might help.
https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
You need to set the environment variable JAVA_HOME in your machine
Related
Launching lib\main.dart on SM A908N in debug mode...
lib\main.dart:1
'D:\flutter' is not recognized as an internal or external command,
operable program or batch file.
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
As per flutter installation it's installed in C:\src\flutter\bin
if you find flutter in this location C:\src\flutter\bin then, go to Environmental variable and set the Path to C:\src\flutter\bin after this close all you're terminal restart your pc to make sure then run flutter doctor in terminal this might help you get going I hope.
You set worng flutter path , ur path should be "D:\flutter\bin"
I didn't change anything in my Flutter application and it was running perfectly but when i tried running on real device i got this exception
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bluetoothadapter:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_321 contains a valid JDK installation.
BUILD FAILED in 13s
Exception: Gradle task assembleDebug failed with exit code 1
Check out this post for a workaround:
tools.jar seems to be not in Android Studio classpath on Windows 8
It seems, the tools.jar is not present on every version of Java 8 anymore. Also make sure to use a JDK and not a pure JRE for development.
Maybe it is worth downloading a current version of the JDK from https://adoptopenjdk.net
I am a beginner in flutter application development. And when I Run my flutter default project code on emulator, I face this issue:
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Administrator\StudioProjects\myapp\android\settings.gradle' (C:\Users\Administrator.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 60
Make sure you have the JAVA_HOME in your environment variables.
Example for path:
C:\Program Files\Java\jdk-16.0.2
And check that the flutter doctor is running successfully:
flutter doctor
a guide to setting the JAVA_HOME variable in Windows
https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
I am setting Flutter for the first time and I keep getting this error when trying to run the Flutter code on a Pixel 2 emulator:
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I tried deleting and reinstalling Android Studio and Java SDK, but it does not solve anything.
I tried setting the JAVA_HOME variable in environmental variables with the following path:
C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1
...but nothing, same error.
Thanks for your help
Important Notice:
My android sdk is installed on the D partition, while the Java sdk is on the C drive. Does it matter ?
Open powershell and write java --version
If you dont get the version try to add again the Java_home to path
Nevertheless, I think java home should be on C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1\bin directory
I'm new to flutter, when I created a new project of flutter and run it, this appears :
Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts,
consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Could not find a command named "-".
Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]
Global options:
-h, --help Print this usage information.
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable anonymous analytics.
--disable-analytics Disable anonymous analytics.
Available commands:
analyze Analyze the project's Dart code.
compile Compile Dart to various formats.
create Create a new project.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
migrate Perform a null safety migration on a project or package.
pub Work with packages.
run Run a Dart program.
test Run tests in this package.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 510ms
Exception: Gradle task assembleDebug failed with exit code 64
I'm stuck with this problem, how to solve this?
I have solved this problem. I run this project in my D: directory while my flutter and android SDK was installed in C: directory. So, when I tried to create flutter project in C:, it worked. But, I still can't configure why this problem happened.
#Papskipapap may I ask, if running your project on D: also inculded some path name which contained a "-" (dash) in it? As a rule of thumb: Keep pathnames easy, i.e. without blanks or special characters other than "_" (underscore), many tools just can not handle those...