2016-07-28 88 views
0

這些是運行我的應用程序啓動屏幕時彈出的錯誤。錯誤:無法從app/src/main/AndroidManifest.xml讀取packageName

Error:The markup in the document preceding the root element must be well-formed. 
Error:Cannot read packageName from /Users/akellavamsimeher/AndroidStudioProjects/WILM/app/src/main/AndroidManifest.xml 

我試着解決看到來自stackoverflow的帖子,但我仍然堅持在那。請幫我解決這些錯誤。

這是代碼。

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

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
     android:name="com.pratyuvamgmail.wilm.Splash" /> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 
</application> 

</manifest> 
<activity 
android:name=".MainActivity" 
android:label="@string/app_name" > 
<intent-filter> 
<action 
android:name="com.coderefer.androidsplashscreenexample.MAINACTIVITY"/> 

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

</manifest> 

下面是我的代碼...

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

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar"> 
      android:name="com.pratyuvamgmail.wilm.Splash" /> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 
<activity 
android:name=".MainActivity" 
android:label="@string/app_name" > 
<intent-filter> 
    <action android:name="com.coderefer.androidsplashscreenexample.MAINACTIVITY"/> 

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

    </manifest> 
+0

分享你的AndroidManifest文件,讓你的AndroidManifest.xml文件開頭: W0rmH0le

+0

那麼是代碼? – Apostolos

+0

可能重複的[無法從AndroidManifest.xml讀取packageName](http://stackoverflow.com/questions/32447683/cannot-read-packagename-from-androidmanifest-xml) – Benny

回答

1

第一印象是,你的清單文件(src/main/AndroidManifest.xml)不啓動像如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.package.name" > 
    ... 
</manifest> 

或已無效格式...

分享你的清單文件,然後,我們將能夠看到確切的錯誤

0

你的清單是錯誤的,你有重複標籤關閉清單和一些標籤有錯誤的開放/關閉標籤。

一個簡單的例子是:獲取更多信息

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

<manifest> 
    <application> 

     <activity> 
      <intent-filter> 
       <action /> 
       <category /> 
       <data /> 
      </intent-filter> 
      <meta-data /> 
     </activity> 

     <activity-alias> 
      <intent-filter> . . . </intent-filter> 
      <meta-data /> 
     </activity-alias> 

     <service> 
      <intent-filter> . . . </intent-filter> 
      <meta-data/> 
     </service> 

     <receiver> 
      <intent-filter> . . . </intent-filter> 
      <meta-data /> 
     </receiver> 

     <provider> 
      <grant-uri-permission /> 
      <meta-data /> 
      <path-permission /> 
     </provider> 

     <uses-library /> 

    </application> 

</manifest> 

檢查Android文檔:

https://developer.android.com/guide/topics/manifest/manifest-intro.html

檢查工作的代碼爲你:從

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

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

</manifest> 
+0

嗨,我得到了以下錯誤後,使用上述碼。 – pratyuvam

0

回答here正在檢查applicationId被設置在build.gradledefaultConfig

becausebuild.gradleapplicationId覆蓋在<manifest>package