Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] Android build failed #7816

Closed
timea-sillai opened this issue May 31, 2024 · 25 comments · Fixed by #8083
Closed

[🐛] Android build failed #7816

timea-sillai opened this issue May 31, 2024 · 25 comments · Fixed by #8083
Labels
help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. platform: android plugin: authentication Firebase Authentication Stale type: bug New bug report

Comments

@timea-sillai
Copy link

"@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;
}

@timea-sillai timea-sillai added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels May 31, 2024
@ducsilva
Copy link

i am also getting this error

@ChrisYohann
Copy link

ChrisYohann commented May 31, 2024

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 ?

@devdongwoo
Copy link

I solved it thanks to your help :)

@ducsilva
Copy link

ducsilva commented Jun 3, 2024

I solved it thanks to your help :)

How did you fix it?

@devdongwoo
Copy link

devdongwoo commented Jun 3, 2024

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?

@r-aurejac
Copy link

r-aurejac commented Jun 3, 2024

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;

@ducsilva
Copy link

ducsilva commented Jun 3, 2024

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

@devdongwoo
Copy link

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

@Shervanator
Copy link

We are also having this issue, patching for the moment till a more permanent fix 😊

@mikehardy
Copy link
Collaborator

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 -

- with 21 local on my machine for testing)

If someone wanted to propose a PR, I could happily merge it

@mikehardy mikehardy added platform: android plugin: authentication Firebase Authentication help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. and removed help: needs-triage Issue needs additional investigation/triaging. labels Jun 7, 2024
@Souvik-Maity-au6
Copy link

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

@toronto2v2
Copy link

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

Screenshot 2024-06-20 at 02 18 09 Screenshot 2024-06-20 at 02 18 49

@Sknton
Copy link

Sknton commented Jun 20, 2024

I'm also have this problem after I have installed the firebase auth.

gradle: 8.0.1
jdk: 17
react-native: 0.72.0

@usamaabutt
Copy link

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!

@abhishek-pavesoft
Copy link

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!

@Vidhun-Coderz
Copy link

Vidhun-Coderz commented Jul 10, 2024

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

@Adbhutashra
Copy link

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;
}
}

mikehardy pushed a commit to zxcpoiu/react-native-firebase that referenced this issue Jul 15, 2024
@NooryA
Copy link

NooryA commented Jul 25, 2024

i use jdk 17 and it still causes this issue. anyone have the same problem?

@russellwheatley
Copy link
Member

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

See this comment for why

@mikehardy
Copy link
Collaborator

@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

@apapalillo
Copy link

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. 🤷🏻‍♂️

@CoderSufiyan
Copy link

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.

Copy link

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.

@nrtrjmly
Copy link

nrtrjmly commented Jan 14, 2025

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 #7816 (comment)

@mikehardy
Copy link
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. platform: android plugin: authentication Firebase Authentication Stale type: bug New bug report
Projects
None yet