2015-09-08 29 views
6

閱讀的packageName我有錯誤,在我的Android清單文件:無法從AndroidManifest.xml中

Error:Cannot read packageName from C:\Users\brandon\AndroidStudioProjects\MineDodge2\app\src\main\AndroidManifest.x‌​ml 
Error:The markup in the document preceding the root element must be well-formed. 

我想看看這個網站上,但答案不是爲我工作。

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

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/redjet" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.brandon.MineDodge.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

     <activity 
      android:name="com.example.brandon.MineDodge.Splash" /> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
    </application> 
</manifest> 
+0

什麼是錯誤?嘗試從其中一個「活動」條目中移除「intent-filter」。 – Breavyn

+0

錯誤:無法從C:\ Users \ brandon \ AndroidStudioProjects \ MineDodge2 \ app \ src \ main \ AndroidManifest.xml中讀取packageName – user4192325

+0

@ColinGillespie它仍然不起作用 – user4192325

回答

0

你的第二個<action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />在這裏不允許。 我認爲 ' <清單的xmlns:機器人= 「http://schemas.android.com/apk/res/android」 包= 「com.example.brandon.MineDodge」>

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/redjet" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.example.brandon.MineDodge.MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.brandon.MineDodge.Splash" /> 
</application> 

` 這樣可以。

+0

它仍然不能正常工作 – user4192325

+0

@BrandonT你已經刪除?它仍然不起作用? –

+0

是的,我的飛濺活動 – user4192325

0

爲什麼你提到<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />兩次?從這兩個中刪除任何一個。

+0

其仍然不能正常工作 – user4192325

-1

試試這個,

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

    <application 
     android:icon="@drawable/launchicon" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme"> 

     <activity 
      android:name=".MainActivity" 
      android:screenOrientation="portrait" 
      android:theme="@style/AppBaseThemeTP"> 

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

    <activity 
     android:name=".Splash" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppBaseThemeTP" > 
    </activity> 

    </application> 
    </manifest> 
+0

有什麼不對的人可以告訴我...? –

-2
<activity 
     android:name="com.example.brandon.MineDodge.Splash" /> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
</application> 

改變它中場休息

<activity 
     android:name="com.example.brandon.MineDodge.Splash" /> 
     <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
</application> 
4

的錯誤是非常簡單的,我相當失望與堆棧社會沒有發現它直到現在。

< manifest ... 

應該成爲

<manifest... 

基本上,刪除多餘的空間。那是什麼導致以下錯誤:

Error:The markup in the document preceding the root element must be well-formed. 

此外,用於在MainActivity意圖過濾器,同樣必須用於第二個活動。

希望這個問題得到解決。

+0

在上面清單我仍然有錯誤:無法從路徑讀取包名稱\ AndroidManifest.xml –

+0

xmlns:android =「schemas.android.com/apk/res/android」; 刪除該行末尾的分號。 xml不使用分號 –

3

如果您使用的是舊版本build.grade文件,你應該刪除這些代碼:

sourceSets { 
    main { 
     manifest.srcFile 'AndroidManifest.xml' 
     java.srcDirs = ['src'] 
     res.srcDirs = ['res'] 
    } 
} 

然後,構建>清理項目

+0

如何知道我是否使用舊分號? –

+0

如果您看到此代碼,則表示您使用的是舊版本。 – SandroMarques

0

我在多有這種子項目引起的子項目不匹配頂級build.gradle中的configure(子句。

具體來說,我有

configure(subprojects.findAll { it.name.startsWith("pachymeninx") }) { 

這不符合我的新的子項目稱爲pachymen。但Gradle構建過程沒有發出警告(我看到),而是給pachymen子項目「Cannot read packageName from AndroidManifest.xml」錯誤。

+0

,再一次,剛纔 – WillC

0

那只是因爲您要麼將已經存在的項目及其文件複製到新創建的項目中。從而導致清單衝突。因爲複製的清單屬於其他項目及其路徑。

您需要在您自己的項目文件路徑中重新創建清單文件,並可能手動將其他項目的清單代碼複製到新創建的清單文件中。

相關問題