How to fix java lang error in latest android studio and flutter

How to fix java lang error in latest android studio and flutter

2,557

If you've recently upgraded your android studio to latest version (Electric Eel) and also trying to use latest flutter (3.7.3) you probably have face following error

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

To fix this error in MacOS you need to follow this steps:

1. Download JDK19

2. Open Terminal and run this command cd /Applications/Android\ Studio.app/Contents/jbr

3. Then run this command after ln -s ../jbr jdk

4. And finally, ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

5. Go to Finder->Applications->Android Studio. Right-click on Android Studio application and select Show Package Contents

6. Create new folder jre in folder Contents

7. Copy contents from the jbr folder to the jre folder

8. Ran flutter doctor again

9. Ran flutter doctor --android-licenses

This will fix your flutter issue with latest version of android studio.

- Last updated 1 year ago

Ads

Be the first to leave a comment.

You must login to leave a comment