cordova - 命名空间前缀 android 未定义

标签 cordova phonegap-plugins cordova-plugins phonegap-build

我正在尝试在我的 Telerik 应用程序构建器“https://github.com/fechanique/cordova-plugin-fcm”中使用 FCM 进行推送通知我收到错误
“未定义命名空间前缀 android”和我的功能 getToken 不管用

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
       id="cordova-plugin-fcm"
       version="2.1.1">
<name>FCMPlugin</name>
<description>Cordova FCM Plugin</description>
<license>Apache 2.0</license>
<keywords>cordova, fcm, push, plugin</keywords>

<info>
    Cordova FCM plugin v2.1.1 installed
    For more details visit https://github.com/fechanique/cordova-plugin-fcm
</info>

<js-module src="www/FCMPlugin.js" name="FCMPlugin">
<clobbers target="FCMPlugin" />
</js-module>

<engines>
<engine name="cordova-android" version=">=4.0.0" />
</engines>

<!-- ANDROID CONFIGURATION -->


<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <activity android:exported="true" android:name="com.gae.scaffolder.plugin.FCMPluginActivity" android:launchMode="singleTop">
            <intent-filter>   
                <action android:name="FCM_PLUGIN_ACTIVITY" />  
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>            
        </activity>
        <service android:name="com.gae.scaffolder.plugin.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service android:name="com.gae.scaffolder.plugin.MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
    </config-file>
    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="FCMPlugin" >
                <param name="android-package" value="com.gae.scaffolder.plugin.FCMPlugin"/>
                <param name="onload" value="true" />
            </feature>
    </config-file>

    <framework src="com.google.firebase:firebase-core:+" />
    <framework src="com.google.firebase:firebase-messaging:+" />

    <framework src="src/android/FCMPlugin.gradle" custom="true" type="gradleReference"/>
  <source-file src="src/android/google-services.json" target-dir="src/com/gae/scaffolder/plugin" />
    <source-file src="src/android/FCMPlugin.java" target-dir="src/com/gae/scaffolder/plugin" />
    <source-file src="src/android/MyFirebaseMessagingService.java" target-dir="src/com/gae/scaffolder/plugin" />
    <source-file src="src/android/MyFirebaseInstanceIDService.java" target-dir="src/com/gae/scaffolder/plugin" />
    <source-file src="src/android/FCMPluginActivity.java" target-dir="src/com/gae/scaffolder/plugin" />
</platform>

//function in my script//
 fcmPlugin.getToken(function (token) {
            alert(token);
        });

最佳答案

我是 Cordova 的新手,所以我要在这里冒险。

我在使用 config-file 的 config.xml 中遇到了类似的错误。
为了修复它,我必须添加到小部件标签:

xmlns:android="http://schemas.android.com/apk/res/android"

您可能需要做类似的事情。

关于cordova - 命名空间前缀 android 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42159305/

相关文章:

android - android :minSdkVersion and android:targetSdkVersion in the AndroidManifest. xml 相对于 phoneGap/Cordova 的用途是什么?

cordova - 使用 cordova CLI 将应用程序部署到 WP8 设备

cordova - 找不到变量 : device

javascript - 未捕获的类型错误 : Object #<Object> has no method 'exec' at file:///android_asset/www/index. html

android - 在 Cordova 应用程序中播放音频

android - 为什么 Chromebook 的 Android 我的应用程序是 "Unsupported"?

ios - 找不到模块 com.pushwoosh.plugins.pushwoosh.PushNotification

javascript - PhoneGap 构建嵌入 YouTube 视频

json - HTTP 原生插件 (IONIC 3)

cordova - 获取PhoneGap App版本的插件?