2016-07-08 78 views
0

我試圖讓應用程序簽署分發到Google Play時出現問題。以下是錯誤:Android清單上的錯誤

Error:(22) Error: The <receiver> element must be a direct child of the <application> element [WrongManifestParent] 

而且清單:

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

    <!-- Permisos --> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

    <!-- Optional permission for reliable local dispatching on non-Google Play devices --> 
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 

    <!-- Add the following meta-data for devices running Google Play service. --> 
    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

    <!-- 
     Optionally, register AnalyticsReceiver and AnalyticsService to support background 
     dispatching on non-Google Play devices 
    --> 
    <receiver 
     android:name="com.google.android.gms.analytics.AnalyticsReceiver" 
     android:enabled="true"> 
     <intent-filter> 
      <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" /> 
     </intent-filter> 
    </receiver> 

    <service 
     android:name="com.google.android.gms.analytics.AnalyticsService" 
     android:enabled="true" 
     android:exported="false" /> 

    <!-- 
     Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable 
     installation campaign reporting 
    --> 
    <receiver 
     android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="com.android.vending.INSTALL_REFERRER" /> 
     </intent-filter> 
    </receiver> 

    <service android:name="com.google.android.gms.analytics.CampaignTrackingService" /> 

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

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

    </application> 

</manifest> 

我不知道是什麼導致了這一點。任何幫助表示讚賞。

+0

接收器標籤應該是內部應用程序標籤 –

+0

把接收器和服務標籤內的應用程序標籤 – SripadRaj

+0

錯誤描述包含所有必要信息:)。只需將您的接收器,服務標籤放在應用程序標籤上 – comrade

回答

1

按照Manifest文件結構......

使用本

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

     <!-- Permisos --> 
     <uses-permission android:name="android.permission.INTERNET" /> 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

     <!-- Optional permission for reliable local dispatching on non-Google Play devices --> 
     <uses-permission android:name="android.permission.WAKE_LOCK" /> 



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

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


    <!-- Add the following meta-data for devices running Google Play service. --> 
     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 

     <!-- 
      Optionally, register AnalyticsReceiver and AnalyticsService to support background 
      dispatching on non-Google Play devices 
     --> 
     <receiver 
      android:name="com.google.android.gms.analytics.AnalyticsReceiver" 
      android:enabled="true"> 
      <intent-filter> 
       <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" /> 
      </intent-filter> 
     </receiver> 

     <service 
      android:name="com.google.android.gms.analytics.AnalyticsService" 
      android:enabled="true" 
      android:exported="false" /> 

     <!-- 
      Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable 
      installation campaign reporting 
     --> 
     <receiver 
      android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" 
      android:exported="true"> 
      <intent-filter> 
       <action android:name="com.android.vending.INSTALL_REFERRER" /> 
      </intent-filter> 
     </receiver> 

     <service android:name="com.google.android.gms.analytics.CampaignTrackingService" /> 

     </application> 

    </manifest> 

享受編碼............

1

你的接收機和服務元素應該在應用元素中,這應該工作:

<?xml version="1.0" encoding="utf-8"?> 

<!-- Permisos --> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 

<!-- Optional permission for reliable local dispatching on non-Google Play devices --> 
<uses-permission android:name="android.permission.WAKE_LOCK"/> 

<!-- Add the following meta-data for devices running Google Play service. --> 
<meta-data 
    android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version"/> 

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

      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 
    <service 
     android:name="com.google.android.gms.analytics.AnalyticsService" 
     android:enabled="true" 
     android:exported="false"/> 

    <service android:name="com.google.android.gms.analytics.CampaignTrackingService"/> 

    <!-- 
    Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable 
    installation campaign reporting 
--> 
    <receiver 
     android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="com.android.vending.INSTALL_REFERRER"/> 
     </intent-filter> 
    </receiver> 

    <!-- 
      Optionally, register AnalyticsReceiver and AnalyticsService to support background 
      dispatching on non-Google Play devices 
     --> 
    <receiver 
     android:name="com.google.android.gms.analytics.AnalyticsReceiver" 
     android:enabled="true"> 
     <intent-filter> 
      <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/> 
     </intent-filter> 
    </receiver> 
</application>