简体   繁体   中英

Android App - AndroidManifest.xml does not work

there always comes the massage The < receiver > element must be a direct child of the < application > element . Does anyone no the correct code? I want to ad LeadBolt ADS. But it's a little bit harder than I thought haha.

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testmoney.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="com.<sdpackagename>.ReEngagementService" >
        </service>
        <service android:name="com.<sdkpackagename>.AdBootReceiverService" >
        </service>

        <receiver android:name="<sdkpackagename>.ReEngagement" >
        <receiver android:name="<com.example.testmoney>.BootReceiver" >
        <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
        </receiver>
        </receiver>

     </application>

The correct manifest is (you've placed closing tag to the incorrect place, and please also make sure to replace <sdkpackagename> with a valid name):

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testmoney.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="com.<sdpackagename>.ReEngagementService">
        </service>
        <service android:name="com.<sdkpackagename>.AdBootReceiverService">
        </service>

        <receiver android:name="com.<sdkpackagename>.ReEngagement">
        </receiver>
        <receiver android:name="com.example.testmoney.BootReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>


     </application>

</manifest>

The problem I think is these four lines:

    <service android:name="com.&lt;sdpackagename>.ReEngagementService" >
    </service>
    <service android:name="com.&lt;sdkpackagename>.AdBootReceiverService" >
    </service>

    <receiver android:name="&lt;sdkpackagename>.ReEngagement" >
    <receiver android:name="&lt;com.example.testmoney>.BootReceiver" >

Remove the &lt; and first > in each line and it should work.

EDIT: Try this

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.testmoney.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="com.<sdpackagename>.ReEngagementService" >
    </service>
    <service android:name="com.<sdkpackagename>.AdBootReceiverService" >
    </service>

    <receiver android:name="<sdkpackagename>.ReEngagement" >
    </receiver>
    <receiver android:name="<com.example.testmoney>.BootReceiver" >
    <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
    </receiver>


 </application>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM