Could not open settings generic class cache when building android

Lately I’m running
ionic cap run android --external
and getting the error

Could not open settings generic class cache for settings file '/Users/xxxx/Projects/Mobile/servicefinder/android/settings.gradle' (/Users/xxxx/.gradle/caches/7.0/scripts/e9mpndfhapalb0yx4e9cyujbp).
 BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

Here’s my gradle info

------------------------------------------------------------
Gradle 7.3.2
------------------------------------------------------------

Build time:   2021-12-15 11:22:31 UTC
Revision:     26c186eb63b2b02e68d83b0dbc6ec69ab118653a

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.1 (Oracle Corporation 17.0.1+12-LTS-39)
OS:           Mac OS X 12.0.1 x86_64

And package.json…

{
  "name": "servicefinder",
  "version": "0.10.1",
  "author": "Obinna Ezeilo",
  "homepage": "https://servicefinderapp.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "12.2.14",
    "@angular/core": "12.2.14",
    "@angular/fire": "^7.1.0",
    "@angular/forms": "12.2.14",
    "@angular/platform-browser": "12.2.14",
    "@angular/platform-browser-dynamic": "12.2.14",
    "@angular/router": "12.2.14",
    "@capacitor/android": "3.3.3",
    "@capacitor/app": "1.0.6",
    "@capacitor/camera": "^1.2.1",
    "@capacitor/core": "3.3.2",
    "@capacitor/filesystem": "^1.0.6",
    "@capacitor/haptics": "1.1.3",
    "@capacitor/ios": "3.3.3",
    "@capacitor/keyboard": "1.1.3",
    "@capacitor/push-notifications": "^1.0.7",
    "@capacitor/splash-screen": "^1.2.0",
    "@capacitor/status-bar": "^1.0.6",
    "@capacitor/storage": "^1.2.3",
    "@ionic-native/camera": "5.32.1",
    "@ionic-native/core": "5.32.1",
    "@ionic-native/file": "5.32.1",
    "@ionic-native/firebase-authentication": "^5.32.1",
    "@ionic-native/image-picker": "^5.32.1",
    "@ionic-native/splash-screen": "^5.32.1",
    "@ionic-native/status-bar": "5.32.1",
    "@ionic-native/stripe": "5.32.1",
    "@ionic/angular": "5.6.5",
    "@ionic/pwa-elements": "^3.0.2",
    "@ungap/global-this": "^0.4.4",
    "angular4-paystack": "^3.0.0",
    "angularfire2": "^5.4.2",
    "cordova": "^10.0.0",
    "cordova-ios": "6.2.0",
    "cordova-plugin-androidx": "3.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-image-picker": "^1.1.3",
    "cordova-sqlite-storage": "6.0.0",
    "cordova-support-android-plugin": "1.0.2",
    "cordova-support-google-services": "^1.4.1",
    "core-js": "^3.11.0",
    "firebase": "9.6.1",
    "formidable": "^3.1.5",
    "globalthis": "^1.0.2",
    "npm-check-updates": "^11.5.4",
    "rxfire": "6.0.0",
    "rxjs": "6.6.7",
    "tslib": "2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/architect": "0.1202.13",
    "@angular-devkit/build-angular": "12.2.13",
    "@angular-devkit/core": "12.2.13",
    "@angular-devkit/schematics": "12.2.13",
    "@angular/cli": "12.2.13",
    "@angular/compiler": "12.2.14",
    "@angular/compiler-cli": "12.2.14",
    "@angular/language-service": "12.2.14",
    "@capacitor/cli": "3.3.2",
    "@ionic/angular-toolkit": "3.1.1",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "3.9.1",
    "@types/jasminewd2": "~2.0.10",
    "@types/node": "~15.0.1",
    "codelyzer": "^6.0.1",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-whitelist": "^1.3.4",
    "jasmine-core": "3.9.0",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "^6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "npm-force-resolutions": "0.0.10",
    "protractor": "7.0.0",
    "ts-node": "~9.1.1",
    "tslint": "6.1.3",
    "typescript": "4.3.5"
  },
  "description": "Service Finder",
  "cordova": {
    "plugins": {
      "cordova-plugin-image-picker": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-firebase-authentication": {}
    },
    "platforms": [
      "ios"
    ]
  },
  "resolutions": {
    "@babel/preset-env": "^7.8.7"
  }
}

Any help would be greatly appreciated.

I GOT IT. No need no change your JDK version, follow the steps to resolve the issue:

  • check your java version and remember it, use “java -version” in terminal
  • go to your android studio path installation
  • then in: Android Studio/jre/ open the file named “release”
  • take attention of the value of JAVA_VERSION field
  • if it’s not the same as the java version on your computer, just change it with the version installed on your computer.

That’s it, i hope it will resolve your issue like it resolve mine.