我为另一个项目制作了我的一个工作项目的副本。从那以后我无法让AndroidManifest.xml正常工作。我收到错误The element must be a direct child of the <application> element
或The element type "manifest" must be terminated by the matching end-tag "</manifest>"
错误。我重构了其他所有内容,并没有在我的课程中看到任何错误。只是xml文件很痛苦。这个文件有什么问题?它看起来很好,看起来像我的工作。 Eclipse似乎认为存在错误。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package= "com.mydomain.qsd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.mydomain.qsd.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission
android:name="com.mydomain.qsd.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity
android:name="com.mydomain.qsd.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.mydomain.qsd.SplashScreen"
android:screenOrientation="portrait" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.mydomain.qsd.gcm.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND" />
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.mydomain.qsd" />
</intent-filter>
</receiver>
<service android:name="com.mydomain.qsd.gcm.GCMService"/>
<activity
android:name="com.mydomain.qsd.NotifyActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_notify" />
</activity>
</application>
</manifest>
答案 0 :(得分:4)
您已直接关闭application tag
替换它:
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
由此:
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
编辑:
你必须替换它:
<activity
android:name="com.mydomain.qsd.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"/>
由此:
<activity
android:name="com.mydomain.qsd.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
<小时/> 这:
<activity
android:name="com.mydomain.qsd.SplashScreen"
android:screenOrientation="portrait" />
由此:
<activity
android:name="com.mydomain.qsd.SplashScreen"
android:screenOrientation="portrait" >
<小时/> 这:
<receiver
android:name="com.mydomain.qsd.gcm.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND" />
由此:
<receiver
android:name="com.mydomain.qsd.gcm.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<小时/> 最后这个:
<activity
android:name="com.mydomain.qsd.NotifyActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_notify" />
</activity>
由此:
<activity
android:name="com.mydomain.qsd.NotifyActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_notify" />
答案 1 :(得分:1)
您的应用标记以及活动代码都已自我关闭,因此请将其删除
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" /> <----- remove /