3

I'm using @react-native-firebase/messaging. when I tried to run the project in android it's return error

:react-native-firebase_messaging has not defined a default in project.ext.'react-native'.versions.android.compileSdk in its build.gradle file.
Akshay I
  • 3,675
  • 1
  • 34
  • 57

6 Answers6

6

I've found a solution to this issue. I'm using @react-native-firebase/messaging with firebase Auth and realtime database. this issue produces because of the version. So, I've removed all firebase libraries and reinstall it and it's working now

Akshay I
  • 3,675
  • 1
  • 34
  • 57
  • The actual problem was not keeping the firebase/app and concerned dependency like firebase/messaging or firebase/crashlytics in sync or of same version. Thus, npm uninstall all the @react-native-firebase/***** libs present in you package.json and then install afresh all of them again. This way the latest version of all will be used and it should work. – saurabh Feb 24 '21 at 17:13
3

I was also getting similar error for crashlytics-

* What went wrong:
A problem occurred evaluating project ':react-native-firebase_crashlytics'.
> :react-native-firebase_crashlytics has not defined a default in project.ext.'react-native'.versions.android.compileSdk in its build.gradle file.

I was using "@react-native-firebase/crashlytics": "8.4.5", downgrading it to "@react-native-firebase/crashlytics": "8.2.1" worked for me.

Varun Kumar
  • 2,543
  • 1
  • 23
  • 22
1

upgrading all the firebase dependencies worked for me

  • Can you please tell me how you were able to upgrade all of the dependencies? Did you use a command, or do it one by one? – Jonathan Feb 04 '21 at 07:19
1

this works on my project:

I use "@react-native-firebase/messaging": "^7.4.2"

I changed the file node_modules/@react-native-firebase/messaging/android/build.gradle

    minSdk    : 16,
    targetSdk : 28,
    compileSdk: 28,
    buildTools: "28.0.3"
1

Never downgrade your packages! You should be always up-to-date!

My problem was that I installed a part of @react-native-firebase/{package}s and after a couple of months later I installed another part of that {package}s. The solution is to install all these (or whose which you need) packages at the same time:

npm install --save @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/database @react-native-firebase/firestore @react-native-firebase/messaging @react-native-firebase/storage

spatak
  • 1,039
  • 1
  • 14
  • 25
0

This works on my project

I run npx jetify on my project root folder

RK.KR
  • 1
  • 1