2012-07-26 34 views
3

我有Eclipse來生成一個基本的Android Hello World應用程序,但它有2個錯誤:首先,在我的AndroidManifest.xml中,這兩行:
我得到根元素之後的文檔中的標記必須格式良好,無論我多少次清理項目,我的R.java都不會生成。任何答案?AndroidManifest.xml根元素之後的文檔中的標記必須格式良好

清單是在這裏:http://jsfiddle.net/NHDU6/

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

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

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MainActivity" 
      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> 


<!-- 
    Declare the contents of this Android application. The namespace 
    attribute brings in the Android platform namespace, and the package 
    supplies a unique name for the application. When writing your 
    own application, the package name must be changed from "com.example.*" 
    to come from a domain that you own or have control over. 
--> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.jfkingsley.maclogin" > 

    <uses-permission android:name="android.permission.CALL_PHONE" /> 
    <uses-permission android:name="android.permission.GET_TASKS" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
    <uses-permission android:name="android.permission.SET_WALLPAPER" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> 

    <application 
     android:icon="@drawable/ic_launcher_home" 
     android:label="@string/home_title" > 
     <activity 
      android:name="Home" 
      android:launchMode="singleInstance" 
      android:stateNotNeeded="true" 
      android:theme="@style/Theme" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.HOME" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name="Wallpaper" 
      android:icon="@drawable/bg_android_icon" 
      android:label="Wallpaper" > 
      <intent-filter> 
       <action android:name="android.intent.action.SET_WALLPAPER" /> 

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

</manifest> 

感謝,喬納森

+3

發表您的清單 – 2012-07-26 11:37:08

+0

您是否刪除了一個項目,然後創建了另一個具有相同名稱的項目? – 2012-11-10 12:11:46

+0

不,問題是我有多個應用程序標記 – Excalibur 2012-11-10 14:04:56

回答

1

這是你的清單,

你不應該指定一個以上的Manifest,你不應該指定多個<application>標籤。

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

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="15" /> 

    <uses-permission android:name="android.permission.CALL_PHONE" /> 
    <uses-permission android:name="android.permission.GET_TASKS" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
    <uses-permission android:name="android.permission.SET_WALLPAPER" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="h" > 
     <activity 
      android:name=".MainActivity" 
      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> 
     <activity 
      android:name="Home" 
      android:launchMode="singleInstance" 
      android:stateNotNeeded="true" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.HOME" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name="Wallpaper" 
      android:icon="@drawable/ic_launcher" 
      android:label="Wallpaper" > 
      <intent-filter> 
       <action android:name="android.intent.action.SET_WALLPAPER" /> 

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

</manifest> 
1

這可能是你失去了一些東西,但有時做一個簡單的代碼重新格式化:CTRL + SHIFT + F,清除問題。

+0

嘗試過它,它不起作用 – Excalibur 2012-07-27 14:05:33

0

我看着你的清單文件。錯誤是由於您有兩個聲明<manifest />標記而引起的。

它始於:

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

然後一些評論是和另一個聲明開始:

<!-- 
    Declare the contents of this Android application. The namespace 
    attribute brings in the Android platform namespace, and the package 
    supplies a unique name for the application. When writing your 
    own application, the package name must be changed from "com.example.*" 
    to come from a domain that you own or have control over. 
--> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.jfkingsley.maclogin" > 

    <uses-permission android:name="android.permission.CALL_PHONE" /> 

你要麼忘了發表意見的清單標籤之一,迷茫的東西,或者下面的錯誤教程。該AndroidManifest文件只能有一個<manifest />標籤

+0

但如果我嘗試刪除其中一個標記,我得到另一個錯誤 – Excalibur 2012-07-27 16:12:15

0

自動生成的AndroidManifest.xml文件本身存在一些問題。裏面有兩個清單標籤和兩個使用sdk標籤。那就是問題所在。別如下: 1-刪除第一清單標籤的結束標記是:所述第二清單標籤的 </manifest> 2-刪除定義標籤,其是:

<manifest 
xmlns:android="http://schemas.android.com/apk/res/android" 
package="net.learn2develop.fragments" 
android:versionCode="1" 
android:versionName="1.0" > 

3-如果有兩個用途-SDK標記,同時刪除第二個uses-sdk標記。

-1

/>不應該在我有同樣的問題,錯誤的文件結束意味着XML文件格式不正確,你應該嘗試刪除/在前面>或者乾脆重新

+1

在文件末尾沒有'/>'在問題中。你在說什麼? – t0mppa 2013-12-31 23:50:10

相關問題