I’m having trouble running the basic Flutter Template App on Android emulator on MacOS M1
- I’ve installed the right emulator I think
It opens correctly
but when I try to run flutter run
on it I get the following error :
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/user/flutter_counter_app/android/build.gradle'
* What went wrong:
Could not compile build file '/Users/user/flutter_counter_app/android/build.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 60
java.lang.IllegalArgumentException: Unsupported class file major version 60
...
1 error
BUILD FAILED in 2s
Running Gradle task 'assembleDebug'... 2 928ms
Exception: Gradle task assembleDebug failed with exit code 1
Everything works on iOS simulator but I’d like to get Android emulator running my Apps too..
flutter doctor -v
[✓] Flutter (Channel beta, 2.9.0-0.1.pre, on macOS 12.0.1 21A559 darwin-arm)
• Flutter version 2.9.0-0.1.pre at /Users/user/FlutterSDK/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8f1f9c10f0 (4 weeks ago), 2021-12-14 13:41:48 -0800
• Engine revision 234aca678a
• Dart version 2.16.0 (build 2.16.0-80.1.beta)
• DevTools version 2.9.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/user/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at:
/Users/user/Library/Java/JavaVirtualMachines/azul-16.0.1/Contents/Home
/bin/java
• Java version OpenJDK Runtime Environment Zulu16.30+19-CA (build 16.0.1+9)
• All Android licenses accepted.
[✓] 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
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
[✓] Connected device (2 available)
2
Answers
Figured it out thanks to Felipe Vergara 💪
-> Had to downgrade Java JDK version by going inside Android Studio -
File
->Project Structure
from16.0
to11
and download a new Java JDK
then delete the version which was to high in
/Library/Java/JavaVirtualMachines/
in root directory I updated the export
JAVA_HOME=
pathclosed Android Studio and restart Terminal
Run
flutter doctor -v
now run
flutter run
in your Android Emulator it should work !For Mac m1 Silicon chip you need to do some extra modification. Just go to your terminal and try this command: