react-native-keychain
react-native-keychain copied to clipboard
Method references are not supported in -source 1.7 in android
method references are not supported in -source 1.7react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java:157: error: method references are not supported in -source 1.7 final Thread warmingUp = new Thread(instance::internalWarmingBestCipher, "keychain-warming-up"); We are using Java 8 , still its showing error .
We are also facing similar error
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)
Go to KeychainModule.java and use the IDE suggestion to increase the language level to 8, this seemed to work for me, or at least allowed a successful build now.
Adding this
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Into the android section of node_modules/react-native-keychain/android/build.gradle
android {
compileSdkVersion safeExtGet('compileSdkVersion', 31)
buildToolsVersion safeExtGet('buildToolsVersion', '31.0.0')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
compileSdkVersion safeExtGet('compileSdkVersion', 31)
targetSdkVersion safeExtGet('targetSdkVersion', 31)
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
Go to KeychainModule.java and use the IDE suggestion to increase the language level to 8, this seemed to work for me, or at least allowed a successful build now.
I actually only saw this once and I don't think it worked for release builds. I had to add some other things like: kotlinOptions { jvmTarget="1.8" }
I had the same issue when updating to the current version, adding the following to the android/build.gradle of the app itself solved the issue, no need to change the module directly:
allprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
}
}
I had the same issue when updating to the current version, adding the following to the android/build.gradle of the app itself solved the issue, no need to change the module directly:
allprojects { afterEvaluate { project -> if (project.hasProperty("android")) { android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } } } }
This works but if you try to create a release build, you're likely to get the
Unsupported class file major version 59
error.
After an update to gradle 7 and RN 0.68.3 this issue is gone, so I believe this error is due to an outdated gradle version.
I had the same issue when updating to the current version, adding the following to the android/build.gradle of the app itself solved the issue, no need to change the module directly:
allprojects { afterEvaluate { project -> if (project.hasProperty("android")) { android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } } } }
this fixed my problem TY so much!