Android签名apk构建错误:<service>元素必须是<application>元素

时间:2016-10-01 10:07:27

标签: android android-manifest signed-apk

我的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.amedya.amedyaeu">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="eu.amedya.amedyaeu.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

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

    <service
        android:name=".IDServisi" >
        <intent-filter>
            <action
                android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
</manifest>

Firebase云消息传递和Android WebView项目。 错误:(14)错误:元素必须是元素的直接子元素[WrongManifestParent]

提前感谢您的帮助。

感谢您的回复。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.amedya.amedyaeu">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="eu.amedya.amedyaeu.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

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

    <service
        android:name=".IDServisi" >
        <intent-filter>
            <action
                android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
    </application>

4 个答案:

答案 0 :(得分:2)

结帐官方文档https://developer.android.com/guide/topics/manifest/manifest-intro.html

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.amedya.amedyaeu">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="eu.amedya.amedyaeu.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

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

    <service
        android:name=".IDServisi" >
        <intent-filter>
            <action
                android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
    </application>


</manifest>

答案 1 :(得分:0)

用以下内容替换您的mentifest文件:

   <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="eu.amedya.amedyaeu">
        <uses-permission android:name="android.permission.INTERNET" />
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity
                android:name="eu.amedya.amedyaeu.MainActivity"
                android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

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

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

        <service
            android:name=".IDServisi" >
            <intent-filter>
                <action
                    android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
        </application>


    </manifest>

答案 2 :(得分:0)

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

    <service
        android:name=".IDServisi" >
        <intent-filter>
            <action
                android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>

将这些行放在应用程序标记

快乐编码!!

答案 3 :(得分:0)

将这些标记放入您的application标记中,如下所示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="eu.amedya.amedyaeu">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name="eu.amedya.amedyaeu.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

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

        <service
            android:name=".IDServisi" >
            <intent-filter>
                <action
                    android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>
    </application>
</manifest>