I'm trying to build my Flutter app and I keep running into an issue where the build fails and throws the following errors:
Task :permission_handler:compileDebugJavaWithJavac FAILED
/Users/ralph/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-6.1.3/android/src/main/java/com/baseflow/permissionhandler/ServiceManager.java:152: warning: [deprecation] getDefaultAdapter() in BluetoothAdapter has been deprecated
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
^
error: warnings found and -Werror specified
1 error
1 warning
warnings found and -Werror specified
Below is my output from flutter doctor -v:
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.0.1 21A559 darwin-arm, locale en-US)
• Flutter version 2.10.0 at /Users/ralph/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5f105a6ca7 (11 days ago), 2022-02-01 14:15:42 -0800
• Engine revision 776efd2034
• Dart version 2.16.0
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/ralph/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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.11+0-b60-7772763)
[✓] VS Code (version 1.64.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.34.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
The thing is I am not even using permission_handler in my project dependencies.
Below are my project dependencies:
cupertino_icons: ^1.0.2
get: 4.1.4
image_picker: any
image_cropper: any
flutter_image_compress: any
universal_html: any
intl_phone_number_input: 0.7.0+2
step_progress_indicator: 1.0.1
intl: 0.17.0
shared_preferences: any
otp_text_field: 1.1.1
connectivity: 3.0.6
readmore: 2.1.0
google_fonts: 2.1.0
otp_count_down: 1.0.6
firebase_messaging: any
flutter_local_notifications: any
firebase_core: any
flutter_svg: 0.22.0
table_calendar: 3.0.1
flutter_time_picker_spinner: 2.0.0
google_maps_flutter: any
custom_info_window: any
bubble: 1.2.1
double_back_to_close_app: 2.0.1
group_radio_button: 1.1.0
graphql_flutter: 5.0.0
hive: any
hive_flutter: any
path_provider: any
google_maps_place_picker: any
flutter_speed_dial: 4.2.0
emoji_picker: any
emoji_picker_flutter: 1.0.6
flutter_slidable: 0.6.0
firebase_auth: any
amplify_auth_cognito: any
amplify_flutter: any
amplify_datastore: any
amplify_api: any
amplify_storage_s3: 0.2.2
crypto: 3.0.1
latlong: 0.6.1
geolocator: 7.7.1
flutter_native_splash: 1.2.2
skeleton_loader: 2.0.0+4
cached_network_image: 3.1.0
emojis: 0.9.3
autocomplete_textfield: 1.7.3
mqtt_client: 9.6.0
pull_to_refresh: 2.0.0
flutter_cache_manager: 3.1.2
wc_flutter_share: 0.4.0
custom_refresh_indicator: 1.0.0
flutter_contacts: 1.1.1+2
grouped_list: 4.1.0
full_screen_image: 1.0.2
loadmore: 2.0.1
flutter_dotenv: 5.0.2
stamp_image: 0.0.2
proste_bezier_curve: 2.0.2
screenshot: 1.2.3
flutter_autolink_text: 1.0.0+1
url_launcher: any
flutter_offline: 2.0.0
internet_connection_checker: 0.0.1+3
flutter_rating_bar: 4.0.0
get_storage: 2.0.3
twilio_flutter: 0.0.9
upgrader: any
google_ml_vision: 0.0.7
How do I resolve this issue ??
Actually google_maps_place_picker uses permission_handler see attached image
try override package to lates version
user
dependency_overrides:
permission_handler: latest version
current latest version for permission_handler ^ 8.3.0
then do flutter clean && flutter pub get
Solution 2 : use other updated package as google_maps_place_picker last update 14 month ago
try one of the following
, run
flutter clean
then restart the emulator
, run
flutter pub get
then restart the emulator
hope its work
Related
On Windows, i work with Flutter using Android Studio.
Since i was facing some issues before this one, i have successfully uninstalled and reinstalled the latest versions of both Android Studio and Java.
So, on this machine, i have:
Android Studio Electric Eel 2022.1.1.19
jdk 19 C:\Program Files\Java\jdk-19
jre 1.8 C:\Program Files\Java\jre1.8.0_361
Since Android Studio uses its own jre, i have copy-pasted the content of jdk folder into C:\Program Files\Android\Android Studio\jre
Environment variables are properly set: JAVA_HOME leads to C:\Program Files\Java\jdk-19 and Path contains both C:\Program Files\Java\jdk-19\bin and C:\Program Files\Java\jre1.8.0_361\bin
This is the problem i'm facing now if i try to build my flutter project:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':device_info_plus:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Android\Android Studio\jre contains a valid JDK installation.
* 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 13s
Exception: Gradle task assembleDebug failed with exit code 1
Now, the main problem is that the file tools.jar DOES NOT EXIST AT ALL.
Is there a way to fix this?
Side Notes:
flutter doctor -v
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Versione 10.0.19045.2486], locale it-IT)
• Flutter version 3.3.10 on channel stable at C:\Users\~\sdks\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (5 weeks ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\~\AppData\Local\Android\sdk
• Platform android-33, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Professional
• Visual Studio Professional 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.1)
• 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 Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
[√] VS Code (version 1.74.3)
• VS Code at C:\Users\~\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.56.0
[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versione 10.0.19045.2486]
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.125
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.55
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Android Studio builds and launches native Android apps without any issue
Eventually i found the solution: here it is, hoping to help someone in the future.
Note: I had to download the jdk-17 because as of today jdk-19 would not work with flutter.
You need to add the path to find your java jdk into your projectfolder/android/gradle.properties file.
simply add this line
org.gradle.java.home=C\:\\Program Files\\Java\\jdk-17
here's my gradle.properties file to give an example
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.bundle.enableUncompressedNativeLibs=false
org.gradle.java.home=C\:\\Program Files\\Java\\jdk-17
If you installed jdk into another path, you need to specify that in here
This question already has answers here:
Unable to find bundled Java version on Flutter
(38 answers)
Closed 14 days ago.
flutter doctor -v fails due to missing Java:
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US)
• Flutter version 3.3.10 on channel stable at /opt/homebrew/Caskroom/flutter/3.3.10/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (4 weeks ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/hahnemann/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Library/Java/JavaVirtualMachines/temurin-19.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Temurin-19.0.1+10 (build 19.0.1+10)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] 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.
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.48.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.87
[✓] HTTP Host Availability
• All required HTTP hosts are available
I have Java installed from Adoptium using Brew. I already tried flutter doctor --android-licenses and removed the obsolete version of Android SDK Tools:
What could be wrong?
Follow these steps:
Go to Applications folder and find Android Studio app
Right click on it and hit Show Package Contents
Navigate to Contents, then right click on "jbr"
Hit duplicate
Rename the duplicate folder to "jre"
Done!!
Apparently it's an open issue with Android Studio Electric Eel 2022.1.1 after I upgraded using Brew. The workaround is:
cd /Applications/Android\ Studio.app/Contents
ln -s jbr jre
On Linux Operating System do this
cd /opt/android-studio
then
ln -s jbr jre
For Windows you can try this:
Open a terminal with admin permissions (e.g. Press Win and type "cmd", "powershell" or "terminal", whatever you prefer, and press Ctrl+Shift+Enter)
Then type:
cd C:\Program Files\Android\Android Studio
mklink /D "jre" "jbr"
Hints
If you have installed Android Studio in a different directory change the path.
If there is a almost jre directory you can simply delete it with rmdir /s jre this was the case on my system after an update to Electric Eel (2022.1.1).
I used to work with Flutter v2.8 as much as I expected. because of the Firebase, I had to update flutter to v3 to get it to work.
After updating Flutter to v3, flutter said, "You have to get JDK version 11 or newer". I got confused why it was saying that because "flutter.dev" has mentioned the appropriate version of JDK for flutter is 8 so far!
I updated my JDK to 11 then, I got these weird errors that I've never had before! every time that I run or build an app it says something like the following pictures:
I created this project by using this command: flutter create projectName
Flutter doctor:
[✓] Flutter (Channel stable, 3.3.0, on Arch Linux 5.17.4-arch1-1, locale en_US.UTF-8)
• Flutter version 3.3.0 on channel stable at /home/john/Android/Flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffccd96b62 (10 days ago), 2022-08-29 17:28:57 -0700
• Engine revision 5e9e0e0aa8
• Dart version 2.10
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /home/john/Android/Android/android-sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /home/john/Android/Android/android-sdk
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+10)
• All Android licenses accepted
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 13.0.1
• cmake version 3.23.1
• ninja version 1.10.2
• pkg-config version 1.8.0
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] IntelliJ IDEA Community Edition (version 2021.3)
• IntelliJ at /usr/share/idea
• Flutter plugin version 70.0.3
• Dart plugin version 213.5744.122
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Arch Linux 5.17.4-arch1-1
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
I've tried to delete ~/.gradle/cache all the time. but cannot produce an .apk app.
tried to downgrade flutter to version 2.8 but again still have the error.
for more information see this GitHub link
(I created this project by using this command: flutter create projectName)
Try to create a new flutter project and copy the files from the current project.
When running flutter build apk I get the following:
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50/50ad05ea1c2595fb31b800e76db464d08d599af3/kotlin-stdlib-jdk7-1.3.50.jar (version 1.3)
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50/b529d1738c7e98bbfa36a4134039528f2ce78ebf/kotlin-stdlib-1.3.50.jar (version 1.3)
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50/3d9cd3e1bc7b92e95f43d45be3bfbcf38e36ab87/kotlin-stdlib-common-1.3.50.jar (version 1.3)
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
C:/Users/username/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
I have already done some of the suggestions I've found online and in this group but so far nothing have worked. In android\build.gradle:
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
classpath "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.10"
classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
}
}
And in app\build.gradle:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.10"
}
I've also ran flutter pub upgrade --major-versions
I've been able to build my apk no problem before, I added workmanager to my pubsec.yaml and this issue started coming up, however I removed the package and the issue still persists. Any help appreciated I've been stuck on this for awhile!
Output of flutter doctor -v
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19041.1288], locale en-BZ)
• Flutter version 2.2.2 at C:\flutter
• Framework revision d79295af24 (4 months ago), 2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\username\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.2)
• 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 11.0.8+10-b944.6842174)
[√] IntelliJ IDEA Community Edition (version 2021.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1.2
• Flutter plugin version 57.0.5
• Dart plugin version 211.7665
[√] VS Code (version 1.59.1)
• VS Code at C:\Users\kvernon\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.81
• Edge (web) • edge • web-javascript • Microsoft Edge 94.0.992.47
• No issues found!
use
ext.kotlin_version = '1.6.10'
and Change jdk7 to Java jdk8
before
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
after
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
replace jdk7 with jdk8 in app/build.gradle file under the dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
with
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Came back to this after having the same problem and couldn't figure out what I did the first time but basically I needed to figure out how to upgrade the gradle version in android/app/build.gradle: classpath 'com.android.tools.build:gradle:7.3.1' (I had this on 4.2.2)
Then I had to make the same update in android/gradle/wrapper/gradle-wrapper.properties like so distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
Then built with no errors.
I got the same problem after installing the qr_code_scanner, and changing biuld.gradle as described here: https://pub.dev/packages/qr_code_scanner
than I got warnings from build apk
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.61/70dffc5f8ac5ea7c34f30deac5b9d8b1d48af066/kotlin-stdlib-jdk7-1.3.61.jar (version 1.3)
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.61/4702105e97f7396ae41b113fdbdc180ec1eb1e36/kotlin-stdlib-1.3.61.jar (version 1.3)
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.61/65abb71d5afb850b68be03987b08e2c864ca3110/kotlin-stdlib-common-1.3.61.jar (version 1.3)
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.10/c49d0703d16c6cb1526cc07b9b46486da1dd8a60/kotlin-stdlib-jdk7-1.5.10.jar (version 1.5)
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.10/da6a904b132f0402fa4d79169a3c1770598d4702/kotlin-stdlib-1.5.10.jar (version 1.5)
/home/ivan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.10/6b84d926e28493be69daf673e40076f89492ef7/kotlin-stdlib-common-1.5.10.jar (version 1.5)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
so, I remove that lib and undo my changes, and that fix it.
If workmanager change your build.gradle and gradle-wrapper.properties, you probably should change it back to previous version.
I'm editing java files in a package of my flutter project, but it is build with source 1.7, how can I change it?
[√] Flutter (Channel dev, 1.27.0-8.0.pre, on Microsoft Windows [Version 10.0.18363.1440], locale ru-RU)
• Flutter version 1.27.0-8.0.pre at C:\Users\USER\flutter
• Framework revision b7d4806243 (5 weeks ago), 2021-02-19 09:22:45 -0800
• Engine revision 6993cb229b
• Dart version 2.13.0 (build 2.13.0-30.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\USER\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• 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.
[√] Android Studio (version 4.1.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)
Make the switch to JDK 11 by following the steps in this post. Once done, restart Android Studio and try clearing its cache.