gpt4 book ai didi

javascript - 无法使用 Firebase Messaging 编译 React Native 应用程序?

转载 作者:行者123 更新时间:2023-12-02 23:40:07 25 4
gpt4 key购买 nike

我想在后台或当我在应用程序中 Activity 时在我的应用程序中显示通知

我可以获取 token 并在 Console Firebase 中手动发送它,并且工作正常,因为我看到“状态已完成”,但应用程序遇到了此问题

我正在使用

react-native-fcm ,

react-native-firebase

这是 AndroidManifest.xml 文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.khadamaty">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />


<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_notif"/>


<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">

<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="my_default_channel"/>
<service
android:name=".java.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBb825RsIEAkFwJKk4PEb12cTXASe9sX70"/>

<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />


</application>

</manifest>

--错误日志

Android resource linking failed
Output: D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:21: error: resource mipmap/ic_notif (aka com.khadamaty:mipmap/ic_notif) not found.
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:78: error: resource color/colorAccent (aka com.khadamaty:color/colorAccent) not found.
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:81: error: resource drawable/ic_stat_ic_notification (aka com.khadamaty:drawable/ic_stat_ic_notification) not found.
error: failed processing manifest.

Command: C:\Users\jit\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\eaad08a303d2763f912063e432550147\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
C:\Users\jit\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
--manifest\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.khadamaty\
-0\
apk\
--output-text-symbols\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
Output: D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:21: AAPT: error: resource mipmap/ic_notif (aka com.khadamaty:mipmap/ic_notif) not found.

D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:78: AAPT: error: resource color/colorAccent (aka com.khadamaty:color/colorAccent) not found.

D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:81: AAPT: error: resource drawable/ic_stat_ic_notification (aka com.khadamaty:drawable/ic_stat_ic_notification) not found.

error: failed processing manifest.
Command: C:\Users\jit\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\eaad08a303d2763f912063e432550147\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
C:\Users\jit\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
--manifest\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.khadamaty\
-0\
apk\
--output-text-symbols\
D:\Last Year\Second\Graduation project\khadamati_app\android\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

最佳答案

错误消息表明您缺少图像和颜色。最好添加这些。

转到 /android/app/src/main/res/mipmap-* 文件夹并创建 ic_launcher.png 的副本并将其命名为 ic_notif .png。还要在 /android/app/src/main/res/drawable-* 文件夹中创建一个副本(如果不存在则创建它们(drawable-mdpi、drawable-hdpi 等..),将图标的副本命名为 ic_stat_ic_notification.png。创建文件 /android/app/src/main/res/values/colors.xml 并将其添加为内容:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorAccent">#FF0000</color>
</resources>

这应该会使错误消失。您可能错过了安装推送模块代码的一些步骤。

Mipmap/drawable explained

关于javascript - 无法使用 Firebase Messaging 编译 React Native 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56118459/

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