oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.12k stars 515 forks source link

when I run my project, throw this error , how can solve this ? #597

Open vishuk570 opened 1 year ago

vishuk570 commented 1 year ago

buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 <> Task :react-native-keychain:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings 334 actionable tasks: 334 executed Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\tc_SEED_Project\CSD-Seed-App\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\tc_SEED_Project\CSD-Seed-App\node_modules\react-native-geolocation-service\android\src\main\java\com\agontuk\RNFusedLocation\LocationUtils.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: F:\tc_SEED_Project\CSD-Seed-App\node_modules\@react-native-google-signin\google-signin\android\src\main\java\com\reactnativegooglesignin\RNGoogleSigninModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: F:\tc_SEED_Project\CSD-Seed-App\node_modules\@react-native-google-signin\google-signin\android\src\main\java\com\reactnativegooglesignin\RNGoogleSigninModule.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. F:\tc_SEED_Project\CSD-Seed-App\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\cipherStorage\CipherStorageBase.java:528: error: lambda expressions are not supported in -source 7 public static final EncryptStringHandler encrypt = (cipher, key, output) -> { ^ (use -source 8 or higher to enable lambda expressions) F:\tc_SEED_Project\CSD-Seed-App\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\decryptionHandler\DecryptionResultHandlerInteractiveBiometric.java:111: error: method references are not supported in -source 7 activity.runOnUiThread(this::startAuthentication); ^ (use -source 8 or higher to enable method references) F:\tc_SEED_Project\CSD-Seed-App\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\decryptionHandler\DecryptionResultHandlerInteractiveBiometricManualRetry.java:78: error: method references are not supported in -source 7 activity.runOnUiThread(this::startAuthentication); ^ (use -source 8 or higher to enable method references) F:\tc_SEED_Project\CSD-Seed-App\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) 4 errors

FAILURE: Build failed with an exception.

varunkukade commented 1 year ago

@vishuk570 (use -source 8 or higher to enable method references) This suggest that Java JDK version you are using should be same or higher than 8. Check your java version by using java -version in terminal.

if its already greater than 8, then I found one workaround. But this is just a workaround and I am yet to find final solution.

  1. Locate the build.gradle file for the react-native-keychain module. It should be located at node_modules/react-native-keychain/android/build.gradle.
  2. In the build.gradle file, find the android section.
  3. Inside the android section, add the following lines:

codecompileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

  1. This configuration sets the source compatibility and target compatibility to Java 8.
  2. Save the build.gradle file.
  3. Clean build using cd android and ./gradlew clean
  4. Again run the app.
varunkukade commented 1 year ago

Keep check on https://github.com/oblador/react-native-keychain/pull/585