react-native-firebase
react-native-firebase copied to clipboard
[🐛] Android build failed
"@react-native-firebase/auth": "^20.0.0", "react-native": "0.72.6",
Task :react-native-firebase_auth:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
after: ./gradlew build --warning-mode all
Task :react-native-firebase_auth:compileDebugJavaWithJavac FAILED /xxx/xxx/xxx/node_modules/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java:1620: error: pattern matching in instanceof is not supported in -source 11 if (exception instanceof FirebaseAuthUserCollisionException collEx) { ^ (use -source 16 or higher to enable pattern matching in instanceof) 1 error
I saw that the sourceCompatibility is JavaVersion.VERSION_11 but line 1620 from /xx/xx/xx/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java is in java 17 like this: if (exception instanceof FirebaseAuthUserCollisionException collEx) and it should be if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; }
i am also getting this error
Same here, using expo 49 SDK and react-native 0.72.4? I use Java 17 with gradle 7.4.2 is automatically picked during build (instead of gradle 8). Does someone know how to update gradle version using expo ?
I solved it thanks to your help :)
I solved it thanks to your help :)
How did you fix it?
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
I think you forgot a variable and a comma on your corrected line:
FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception;
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
I did the same as you and installed this patch package
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) // exisiting code } " Sorry, My English has a lot of flaws. Did you understand?
I think you forgot a variable and a comma on your corrected line:
FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception;
thanks to you, my corrected line is fixed
We are also having this issue, patching for the moment till a more permanent fix 😊
Interesting, that line of code was a recent fix yes, I didn't realize it broke support for JDK11 - and I'll admit I thought everyone had moved to JDK17+ now (we test with JDK21 and 17, for what it's worth - and why this was invisible to me/us - https://github.com/invertase/react-native-firebase/blob/d849667a1b3614c4a938c1f2bea892758831b368/.github/workflows/tests_e2e_android.yml#L82 - with 21 local on my machine for testing)
If someone wanted to propose a PR, I could happily merge it
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) // exisiting code } " Sorry, My English has a lot of flaws. Did you understand?
I think you forgot a variable and a comma on your corrected line:
FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception;
Gosh same issue is still now resolved by this thank you
Also faced the same error after installing firebase auth gradle: 8.0 jdk: 17 react-native: 0.72.0 @react-native-firebase/auth: 20.1.0,
> Task :react-native-firebase_auth:compileDebugJavaWithJavac FAILED /Users/***/Documents/work/***/***/node_modules/@react-native-firebase/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java:1620: error: pattern matching in instanceof is not supported in -source 11 if (exception instanceof FirebaseAuthUserCollisionException collEx) { ^ (use -source 16 or higher to enable pattern matching in instanceof) 1 error
I'm also have this problem after I have installed the firebase auth.
gradle: 8.0.1 jdk: 17 react-native: 0.72.0
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
This saved my day thanks!
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
Dude don't worry about the English. You're a lifesaver!
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
"@react-native-firebase/app": "^19.2.2", "@react-native-firebase/auth": "^19.2.2", "@react-native-firebase/dynamic-links": "^19.3.0", "react-native": "0.72.7", "react-native-fbsdk-next": "^13.0.0",
I tried above solution but its not working . it cause errors in other packages IDK why.What i have to do next -> any idea
My Solution is
node_modules@react-native-firebase\auth\android\src\main\java\io\invertase\firebase\auth\ReactNativeFirebaseAuthModule.java
Remove : if (exception instanceof FirebaseAuthUserCollisionException collEx) { AuthCredential updatedCredential = collEx.getUpdatedCredential(); Log.d(TAG, "link:onComplete:collisionFailure", collEx); // If we have a credential in the error, we can return it, otherwise fall // through if (updatedCredential != null) { Log.d(TAG, "link:onComplete:collisionFailure had credential", collEx); promiseRejectLinkAuthException(promise, collEx, updatedCredential); return; } }
i use jdk 17 and it still causes this issue. anyone have the same problem?
This is a documentation issue at this point. We ought to specify what minimum JDK + iOS versions are required for RNFB here: https://rnfirebase.io/platforms
@NooryA
i use jdk 17 and it still causes this issue. anyone have the same problem?
I suspect you think you are running JDK17 but you are actually building with some lower JDK. This may seem improbable but it's the only plausible explanation for a build failure when using a language feature that is not available in JDK < 17 and is available in JDK >= 17
@russellwheatley --> suggest adding this along with docs as a hard fail / fast fail in build files:
https://github.com/ankidroid/Anki-Android/blob/91b984a6a12a5d511945e5f7bcf62347f6d0a7fe/build.gradle.kts#L96-L111
I had the same issue despite having the right JDK and everything. It was driving me mad.
But then I simply upgraded React Native from 0.74.5 to 0.75.3 by following the upgrade helper, and it somehow suddenly began working. 🤷🏻♂️
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
Thanks a lot for this.
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
For anyone still seeing this error and you are 100% sure you are running JDK 17 your problem is probably that you are running a react native version that uses AGP android gradle tools 7.* and below.
React native firebase defaults to using jdk11 for any version of AGP below 8.
Check
https://github.com/invertase/react-native-firebase/blob/main/packages/app/android/build.gradle#L84-L89
So stop pulling your hair and just use the patch package solution above or upgrade to a version of react native that uses android gradle tools 8 >.
patch here https://github.com/invertase/react-native-firebase/issues/7816#issuecomment-2145105096
@nrtrjmly Interesting! that's a subtle interaction - missed that in previous analysis of this problem. AGP8+ has been in use long enough that I hadn't tested back far enough to attempt AGP<=8
Indeed it is kind-of-a-bug to have 11 listed for source compatibility since the code is no longer compatible with it. That should have been bumped to 17 at the same time the JDK17+ source feature was added
Thanks a lot for this solution
I solved it thanks to your help :)
How did you fix it?
your "ReactNativeFirebaseAuthModule.java" file change from " if (exception instanceof FirebaseAuthUserCollisionException collEx){ // exisiting code }" to " if (exception instanceof FirebaseAuthUserCollisionException) { FirebaseAuthUserCollisionException collEx = (FirebaseAuthUserCollisionException) exception; // exisiting code } "
Sorry, My English has a lot of flaws. Did you understand?
@devdongwoo is it correct than to run this command?
yarn patch-package @react-native-firebase/auth
It creates a patch package file which is a bit different. Thx again!!