react-native-firebase_messaging 未在 project.ext.'react-native'.versions.android.compileSdk 中定义默认值

react-native-firebase_messaging has not defined a default in project.ext.'react-native'.versions.android.compileSdk

我正在使用 @react-native-firebase/messaging。当我尝试 运行 android 中的项目时,它是 return 错误

:react-native-firebase_messaging has not defined a default in project.ext.'react-native'.versions.android.compileSdk in its build.gradle file.

我找到了解决这个问题的办法。我将 @react-native-firebase/messaging 与 firebase Auth 和实时数据库一起使用。这个问题是因为版本。 所以,我删除了所有 firebase 库并重新安装它,它现在可以工作了

对于 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.

我正在使用 "@react-native-firebase/crashlytics": "8.4.5",将其降级为 "@react-native-firebase/crashlytics": "8.2.1" 对我有用。

升级所有 firebase 依赖项对我有用

这适用于我的项目:

我用 "@react-native-firebase/messaging": "^7.4.2"

我更改了文件node_modules/@react-native-firebase/messaging/android/build.gradle

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

永远不要降级你的包裹!你应该永远 up-to-date!

我的问题是我安装了@react-native-firebase/{package} 的一部分,几个月后我安装了该{package} 的另一部分。 解决方案是同时安装所有这些(或您需要的)软件包:

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

这适用于我的项目

我 运行 npx jetify 在我的项目根文件夹上