oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.18k stars 519 forks source link

Method references are not supported in -source 7 #571

Open jrhager84 opened 1 year ago

jrhager84 commented 1 year ago

Trying to install react-native-keychain in my project, and I keep getting this error:

/path/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java:157: error: method references are not supported in -source 7
    final Thread warmingUp = new Thread(instance::internalWarmingBestCipher, "keychain-warming-up");
                                                  ^
  (use -source 8 or higher to enable method references)

I even tried the manual install to get the correct code in the MainApplication and gradle files. Build fails every time. I can't set my compile version to 29 because reanimated (and other libraries) need some R reference that 29 doesn't have (other things break when I downgrade it). How do I keep version 31+ while allowing a method reference in the Keychain warmup.

Please advise. :)

react native info:

info Fetching system and libraries information...
System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 468.89 MB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.8.0 - /opt/homebrew/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.18.0 - /opt/homebrew/bin/npm
    Watchman: 2022.09.05.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 18.0.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.0 => 0.68.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

package.json

{
  "name": "projectname",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
  },
  "dependencies": {
    "@mux/mux-data-react-native-video": "^0.6.4",
    "@openspacelabs/react-native-zoomable-view": "^2.0.4",
    "@react-native-async-storage/async-storage": "^1.17.10",
    "@react-native-community/blur": "^4.2.0",
    "@react-native-community/netinfo": "^9.3.4",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/drawer": "^6.5.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.0",
    "html-entities": "^2.3.3",
    "native-base": "3.4.0",
    "react": "17.0.2",
    "react-native": "0.68.0",
    "react-native-elements": "^3.4.2",
    "react-native-fast-image": "^8.6.1",
    "react-native-gesture-handler": "^2.7.0",
    "react-native-keychain": "^8.1.1",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-music-control": "^1.4.1",
    "react-native-orientation-locker": "^1.5.0",
    "react-native-reanimated": "^2.10.0",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-screens": "^3.18.0",
    "react-native-share": "^7.9.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^13.4.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-native-system-navigation-bar": "^2.0.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-version-check": "^3.4.3",
    "react-native-video": "^5.2.1",
    "react-native-video-controls": "^2.8.1",
    "react-native-webview": "^11.23.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.64.5",
    "@types/react-native-vector-icons": "^6.4.12",
    "@types/react-native-version-check": "^3.4.4",
    "@types/react-test-renderer": "^16.9.2",
    "babel-jest": "^26.6.3",
    "eslint": "^7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "17.0.1",
    "typescript": "^3.8.3"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}
dave-mp commented 1 year ago

Hello!

I ran into this issue and was able to workaround it by adding the JavaVersion 1.8 to the library in node_modules/react-native-keychain/android/build.gradle:

android {
  ...
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  ...
}

Hopefully this will be patched in an upcoming release 🚀