Home > Enterprise >  Not able to launch Flutter app on Android device
Not able to launch Flutter app on Android device

Time:02-08

I am trying to launch my Flutter app on an Android device, I was able just until yesterday, but suddenly today I am getting this error when launching it:

Launching lib/main.dart on Moto G 5S in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings remapped class cache for 7yvt6la2007dno98lt3rzbguf (/Users/modestovascofornas/.gradle/caches/6.3/scripts-remapped/settings_bwqg3axqhj874bje5e9od2vqv/7yvt6la2007dno98lt3rzbguf/settingsdeec0faa97453e2ce860d75e6bf1604b).
> Could not open settings generic class cache for settings file '/Users/modestovascofornas/desarrollo/DESARROLLO 2022 SSD-2/2022-G2-CAPENERGY-FLUTTER-PROFESIONAL/FLUTTER/flutter_capenergy/android/settings.gradle' (/Users/modestovascofornas/.gradle/caches/6.3/scripts/7yvt6la2007dno98lt3rzbguf/settings/settingsdeec0faa97453e2ce860d75e6bf1604b).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

* 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 24s
Exception: Gradle task assembleDebug failed with exit code 1

I have tried deleting .gradle folder, but not working

EDIT

This is my ~/.zshrc file

export PATH=/Users/modestovascofornas/flutter/bin:$PATH
export PATH=/Users/modestovascofornas/flutter/.pub-cache/bin:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home

CodePudding user response:

Set the JAVA_HOME environment variable to the JRE for Android Studio. For example:

C:\Program Files\Android\Android Studio\jre

Then invalidate and restart Android Studio before trying again.

CodePudding user response:

You could try this:

Open the terminal in your IDE and issue the command:

flutter clean

Try to launch the app again.

CodePudding user response:

have you tried ./gradlew clean after you deleted .gradle ?

In Android Studio i've found it is always best to configure variables through the project structure dialog. Make sure you configured gradle, JDK & SDK for the project correctly there because the last error indicates a conflict with java/gradle version.

Try upgrading gradle via gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

and be sure that you are running java version 11 or lower - whatever version is Android Studio default.

edit: After seeing your edit, i would almost guarantee that the issue is with jdk-17.0.2.jdk be sure to use the bundled JDK and configure the path through the project structure dialog.

  •  Tags:  
  • Related