Cannot build android app - "Could not open settings remapped class cache "

That’s the error i am seeing after trying to run the android app from Android Studio.

(base) MacBook-Air:ReactNativeClient siddhantsehgal$ npm run start-android

Joplin@0.8.0 start-android /Users/siddhantsehgal/Desktop/joplin/ReactNativeClient
react-native run-android

warn The following packages use deprecated “rnpm” config that will stop working from next release:

  • react-native-push-notification: https://github.com/zo0r/react-native-push-notification#readme
    Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
    error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  • react-native-camera (to unlink run: “react-native unlink react-native-camera”)
  • react-native-document-picker (to unlink run: “react-native unlink react-native-document-picker”)
  • react-native-file-viewer (to unlink run: “react-native unlink react-native-file-viewer”)
  • react-native-fs (to unlink run: “react-native unlink react-native-fs”)
  • react-native-image-picker (to unlink run: “react-native unlink react-native-image-picker”)
  • react-native-image-resizer (to unlink run: “react-native unlink react-native-image-resizer”)
  • react-native-push-notification (to unlink run: “react-native unlink react-native-push-notification”)
  • react-native-quick-actions (to unlink run: “react-native unlink react-native-quick-actions”)
  • react-native-securerandom (to unlink run: “react-native unlink react-native-securerandom”)
  • react-native-sqlite-storage (to unlink run: “react-native unlink react-native-sqlite-storage”)
  • react-native-vector-icons (to unlink run: “react-native unlink react-native-vector-icons”)
  • react-native-version-info (to unlink run: “react-native unlink react-native-version-info”)
  • rn-fetch-blob (to unlink run: “react-native unlink rn-fetch-blob”)
    This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn’t compatible with autolinking, disregard this message and notify the library maintainers.
    Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
    info Running jetifier to migrate libraries to AndroidX. You can disable it using “–no-jetifier” flag.
    Jetifier found 1237 file(s) to forward-jetify. Using 4 workers…
    info Starting JS server…
    info Launching emulator…
    info Successfully launched emulator.
    info Installing the app…

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not open settings remapped class cache for 7wvc2u4ag7gjhupwx1t9uob0q (/Users/siddhantsehgal/.gradle/caches/5.5/scripts-remapped/settings_9neja512pd5qj1zvedbhflxjt/7wvc2u4ag7gjhupwx1t9uob0q/settings74e694b976d6abaa826c8abac43e9de8).

Could not open settings generic class cache for settings file ‘/Users/siddhantsehgal/Desktop/joplin/ReactNativeClient/android/settings.gradle’ (/Users/siddhantsehgal/.gradle/caches/5.5/scripts/7wvc2u4ag7gjhupwx1t9uob0q/settings/settings74e694b976d6abaa826c8abac43e9de8).
BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 57

  • 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 1s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not open settings remapped class cache for 7wvc2u4ag7gjhupwx1t9uob0q (/Users/siddhantsehgal/.gradle/caches/5.5/scripts-remapped/settings_9neja512pd5qj1zvedbhflxjt/7wvc2u4ag7gjhupwx1t9uob0q/settings74e694b976d6abaa826c8abac43e9de8).

Could not open settings generic class cache for settings file ‘/Users/siddhantsehgal/Desktop/joplin/ReactNativeClient/android/settings.gradle’ (/Users/siddhantsehgal/.gradle/caches/5.5/scripts/7wvc2u4ag7gjhupwx1t9uob0q/settings/settings74e694b976d6abaa826c8abac43e9de8).
BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 57

  • 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 1s

at checkExecSyncError (child_process.js:602:13)
at execFileSync (child_process.js:622:13)
at runOnAllDevices (/Users/siddhantsehgal/Desktop/joplin/ReactNativeClient/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Joplin@0.8.0 start-android: react-native run-android
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Joplin@0.8.0 start-android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/siddhantsehgal/.npm/_logs/2020-04-09T18_41_49_384Z-debug.log

LOGfile

0 info it worked if it ends with ok
1 verbose cli [ ‘/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/bin/node’,
1 verbose cli ‘/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/bin/npm’,
1 verbose cli ‘run’,
1 verbose cli ‘start-android’ ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ ‘prestart-android’, ‘start-android’, ‘poststart-android’ ]
5 info lifecycle Joplin@0.8.0~prestart-android: Joplin@0.8.0
6 info lifecycle Joplin@0.8.0~start-android: Joplin@0.8.0
7 verbose lifecycle Joplin@0.8.0~start-android: unsafe-perm in lifecycle true
8 verbose lifecycle Joplin@0.8.0~start-android: PATH: /Users/siddhantsehgal/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/siddhantsehgal/Desktop/joplin/ReactNativeClient/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/opt/gettext/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Users/siddhantsehgal/opt/miniconda3/bin:/Users/siddhantsehgal/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/opt/sqlite/bin:/usr/local/opt/openssl/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin:/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/Users/siddhantsehgal/Library/Android/sdk/emulator:/Users/siddhantsehgal/Library/Android/sdk/tools:/Users/siddhantsehgal/Library/Android/sdk/tools/bin:/Users/siddhantsehgal/Library/Android/sdk/platform-tools:/usr/local/mysql/bin
9 verbose lifecycle Joplin@0.8.0~start-android: CWD: /Users/siddhantsehgal/Desktop/joplin/ReactNativeClient
10 silly lifecycle Joplin@0.8.0~start-android: Args: [ ‘-c’, ‘react-native run-android’ ]
11 silly lifecycle Joplin@0.8.0~start-android: Returned: code: 1 signal: null
12 info lifecycle Joplin@0.8.0~start-android: Failed to exec start-android script
13 verbose stack Error: Joplin@0.8.0 start-android: react-native run-android
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:915:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid Joplin@0.8.0
15 verbose cwd /Users/siddhantsehgal/Desktop/joplin/ReactNativeClient
16 verbose Darwin 19.4.0
17 verbose argv “/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/bin/node” “/Users/siddhantsehgal/.nvm/versions/node/v8.12.0/bin/npm” “run” “start-android”
18 verbose node v8.12.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error Joplin@0.8.0 start-android: react-native run-android
22 error Exit status 1
23 error Failed at the Joplin@0.8.0 start-android script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Try following the steps mentioned here: https://stackoverflow.com/a/48052728

1 Like

Thanks. But i followed most of the stackoverflow posts but couldn’t solve my problem by most of them

Can you please tell me what SDK Platform, Android Build Tools and Android SDK version you have installed? You check it in Android Studio > Preferences > Android SDK

Here you can see that.

Okay it took me almost a night. But i solved the problem. The problem was in the version of Java you’re using. If you’re using java version 13 or so, the current or latest which you can check by typing java -version in terminal, but it requires Java 8 to run the application. So you can add this line,
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version" and add it to the .bash_profile.rc file of your system and then you can switch easily between java version 8 and current.
Just enter command : j8 in to your terminal and it will switch to java version 8 and then run npm run start-android to start android application.

1 Like