gpt4 book ai didi

android - react-native-firebase 通知崩溃

转载 作者:行者123 更新时间:2023-11-29 23:31:17 27 4
gpt4 key购买 nike

当在装有 Android OS 8.1.0 的 Android 设备上的模拟器中收到通知时,应用程序崩溃。这发生在应用程序中。当我在应用程序之外并且通知在通知托盘中正常到达时,它不会发生。但是在真实设备上,它在内部和外部都会发生(?)。Android 5.0.0 不会发生崩溃。

Crashlytics 中的错误是:

Caused by java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;Ljava/lang/String;)V in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes (declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/com.parkour2342345-zqe_7U0B_6slVtK2mLk6RA==/base.apk!classes2.dex)
at io.invertase.firebase.notifications.DisplayNotificationTask.doInBackground(DisplayNotificationTask.java:68)
at io.invertase.firebase.notifications.DisplayNotificationTask.doInBackground(DisplayNotificationTask.java:31)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

还有:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

我的 react-native-firebase build.gradle 包含:

def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_FIREBASE_VERSION = "12.0.0"
def DEFAULT_SUPPORT_LIB_VERSION = "27.0.2"

android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
multiDexEnabled true
}

我在这里发布了这个问题: https://github.com/invertase/react-native-firebase/issues/1553

环境

应用目标平台:安卓

开发操作系统:macOS High Sierra 10.13.6

构建工具:安卓工作室:3.1 AI-173.4670197

React Native 版本:0.54.4 => 0.54.4

React Native Firebase 版本:4.3.8

Firebase 模块:消息传递

你在使用 typescript 吗?没有


更新#1:

在 react-native-navigation 的 build.gradle 中:

def DEFAULT_SUPPORT_LIB_VERSION = "27.0.2"
...
def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION

dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
api "com.facebook.react:react-native:+" // From node_modules
api "com.android.support:support-v4:$supportVersion"

项目中似乎没有定义 supportLibVersion,因此我假设它将继承文件中的值。此外,尽管重建项目有效,但它确实将该行突出显示为红色。 enter image description here

最佳答案

解决方案,经过数小时的挫折:1)淘汰线:api“com.android.support:support-v4:$supportVersion”

2) 将 sdk 更改为 27。def DEFAULT_TARGET_SDK_VERSION = 27

从表面上看,这些都不应该解决这个问题,但他们确实......

关于android - react-native-firebase 通知崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52631329/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com