为什么我在 manifest 中为 android 添加 backendless service 时出现错误?

why there is an error when I add backendless service for android in manifest?

当我在清单中为 Android 添加后端服务时,如后端网站的推送通知设置中所示,它给我一个错误,并在第一个服务词

下显示一条红线
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.peter.notify">


<uses-permission android:name="android.permission.INTERNET" />

<service android:name="com.backendless.push.BackendlessFCMService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".LoginPage">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER"     />
        </intent-filter>
    </activity>
    <activity android:name=".RegisterPage" />
    <activity android:name=".MoviesPage" />

</application>

what I expect my app connect with my backendless account, but what I     get it this error 

(Android resource linking failed
Output:  C:\Users\PETER\AndroidStudioProjects\Notify\app\build    \intermediates\instant_run_merged_manifests\debug\processDebugManifest  \instant-run\AndroidManifest.xml:19: error: unexpected element <service>    found in <manifest>.

Command: C:\Users\PETER\.gradle\caches\transforms-1\files-    1.1\aapt2-3.2.1-4818971-windows.jar\efc3d32fb9b1857254999d94d3fe990e\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
    C:\Users\PETER\AppData\Local\Android\Sdk\platforms\android-   28\android.jar\
    --manifest\
    C:\Users\PETER\AndroidStudioProjects\Notify\app\build\intermediates\instant_run_merged_manifests\debug\processDebugManifest\instant-run\AndroidManifest.xml\
    -o\
    C:\Users\PETER\AndroidStudioProjects\Notify\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
    -R\
    @C:\Users\PETER\AndroidStudioProjects\Notify\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
    --auto-add-overlay\
    --java\
    C:\Users\PETER\AndroidStudioProjects\Notify\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
    --custom-package\
    com.example.peter.notify\
    -0\
    apk\
    --preferred-density\
    xxhdpi\
    --output-text-symbols\
    C:\Users\PETER\AndroidStudioProjects\Notify\app\build\intermediates\symbols\debug\R.txt\
    --no-version-vectors

守护进程:AAPT2 aapt2-3.2.1-4818971-windows守护进程 #0)

根据 documentation.

<service> 标签应包含在 <application> 标签中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.peter.notify">


<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".LoginPage">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER"     />
        </intent-filter>
    </activity>
    <activity android:name=".RegisterPage" />
    <activity android:name=".MoviesPage" />

    <service android:name="com.backendless.push.BackendlessFCMService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

</application>

编辑:

确保您的 build.gradle 文件中有这些依赖项,并且您的项目与 Gradle 文件同步。

implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation 'com.backendless:backendless:5.2.4'

您的服务声明放错地方了。它必须低于 <application/>,与您的活动处于同一级别。

在应用程序标签下声明服务(BackendlessFCMService)。