【问题标题】:Android signed apk build error : The <service> element must be a direct child of the <application> elementAndroid 签名 apk 构建错误:<service> 元素必须是 <application> 元素的直接子元素
【发布时间】:2016-10-01 10:07:26
【问题描述】:

我的 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>

【问题讨论】:

    标签: android android-manifest signed-apk


    【解决方案1】:

    查看官方文档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>
    

    【讨论】:

      【解决方案2】:

      用这些替换你的 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>
      

      【讨论】:

        【解决方案3】:
         <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>
        

        将此行放在您的应用程序标签中

        编码愉快!!

        【讨论】:

          【解决方案4】:

          将这些标签放入您的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>
          

          【讨论】:

            猜你喜欢
            • 2021-12-13
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-05-25
            • 1970-01-01
            • 2017-08-26
            • 2020-08-19
            相关资源
            最近更新 更多