I tried build my React Native project for Android after updating from _MacOS Catalina_ to _MacOS Big Sur_ and it failed with this error:
Execution failed for task ':invertase_react-native-apple-authentication:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
I had _Java 1.8_ and _Gradle 6.2_ installed, so I installed the _JDK (version 15)_ and (since it was necessary) _Gradle 6.3_.
Now my build fails with these errors:
/Users/msamsel/Workspace/lunchnow-customer/native/node_modules/@invertase/react-native-apple-authentication/android/src/main/java/com/RNAppleAuthentication/webview/SignInWebViewClient.kt:25: Error: Call requires API level 21 (current min is 16): android.webkit.WebResourceRequest#getMethod [NewApi]
if (request?.method == "POST" && request.url.toString().contains(attempt.redirectUri)) {
~~~~~~
/Users/msamsel/Workspace/lunchnow-customer/native/node_modules/@invertase/react-native-apple-authentication/android/src/main/java/com/RNAppleAuthentication/webview/SignInWebViewClient.kt:25: Error: Call requires API level 21 (current min is 16): android.webkit.WebResourceRequest#getUrl [NewApi]
if (request?.method == "POST" && request.url.toString().contains(attempt.redirectUri)) {
~~~
/Users/msamsel/Workspace/lunchnow-customer/native/node_modules/@invertase/react-native-apple-authentication/android/src/main/java/com/RNAppleAuthentication/webview/SignInWebViewDialogFragment.kt:53: Error: Use requireContext() instead of context!! [UseRequireInsteadOfGet]
val webView = WebView(context!!).apply {
~~~~~~~~~
Last time I checked with the previous setup on _Catalina_, it worked...
Is this a bug in the package?
Also, I don't actually need the package for the Android build, only iOS. Is there a way to just exclude it from the Android build?
Package is fine, I'm running on big sur.
Maybe install openjdk8, and carefully set up JAVA_HOME etc ?
https://reactnative.dev/docs/environment-setup with toggles set for "react-native CLI quickstart", "macos" and "android".
Thanks, after installing openjdk8 and uninstalling all other JDKs, it works ^^
@metawort excellent news! Glad that worked - I was pretty confident that would do it but it's software, you never know...
Good luck on your project
@mikehardy I can't get it to work:
What went wrong:
Execution failed for task ':invertase_react-native-apple-authentication:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
Errors found:
/Users/lucas/apps/test/node_modules/@invertase/react-native-apple-authentication/android/src/main/java/com/RNAppleAuthentication/webview/SignInWebViewDialogFragment.kt:53: Error: Use requireContext() instead of context!! [UseRequireInsteadOfGet]
val webView = WebView(context!!).apply {
~~~~~~~~~
Already installed the JDK from RN docs and sourced it on zsh. But it doesn't work.
@luco I googled and saw this https://bentrengrove.com/blog/2020/6/15/requirecontext-or-context, try it out, if it works post a PR and we can merge it?
@mikehardy It seems that my java location was wrong (not the brew JDK home). Pointing to it on zshrc fixed it. Thanks!
Most helpful comment
Package is fine, I'm running on big sur.
Maybe install openjdk8, and carefully set up JAVA_HOME etc ?
https://reactnative.dev/docs/environment-setup with toggles set for "react-native CLI quickstart", "macos" and "android".