Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"AndroidManifest.xml does not declare a Java package" error

Tags:

android

This may be more of a Linux bug than a programming error, but I am not sure. The AndroidManifest.xml is somewhat Greek to me. That said, my program has compiled and run before in it's current state perfectly fine, it is even on the Market. Its been around a month since I've opened the source in Eclipse, and today when I opened it, it refused to compile and displays the following errors:

[2010-12-10 10:43:19 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read /media/DATA/code/Android/XXX/AndroidManifest.xml: org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/XXX/AndroidManifest.xml'.

[2010-12-10 10:43:19 - XXX] AndroidManifest.xml does not declare a Java package: Build aborted.

where XXX is the package name (and directory it is located). I have confirmed that the file is perfectly fine in a text editor, and even refreshed it in Eclipse. Nothing.

I updated the ADT...maybe the criteria for AndroidManifest.xml changed?

My AndroidManifest.xml:

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

 <application android:icon="@drawable/icon" android:label="@string/app_name">

     <activity 
      android:name=".XXX"
   android:label="@string/app_name"
   android:screenOrientation="portrait"

   android:theme="@android:style/Theme.NoTitleBar"
   >

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

   </intent-filter>
  </activity>

  <activity 
   android:name=".FindLocationsActivity"
   android:screenOrientation="portrait"
   >
  </activity>

  <activity 
   android:name=".DeveloperActivity"
   android:screenOrientation="portrait"
  >
  </activity>

  <activity 
   android:name=".LegalActivity"
   android:screenOrientation="portrait"
  >
  </activity>

  <activity 
   android:name=".AboutActivity"
   android:screenOrientation="portrait"
  >
  </activity>

  <activity 
   android:name=".SettingsAndAboutActivity"
   android:screenOrientation="portrait"
   >
  </activity>

  <activity
   android:name=".ResultsPageActivity"
   android:screenOrientation="portrait"
   >
  </activity>

    </application>
<uses-sdk android:minSdkVersion="1" 
/>

</manifest> 
like image 576
Brandon Avatar asked Dec 10 '10 17:12

Brandon


3 Answers

This exception is not Android related:

[2010-12-10 10:43:19 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read /media/DATA/code/Android/XXX/AndroidManifest.xml: org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/XXX/AndroidManifest.xml'.

It means the file that is loaded in the Eclipse editor is not the same as the one on the filesystem.

Click the resource (or even better, the eclipse project) in the navigator or package explorer view, right click and select 'Refresh.'

Whether or not this will completely fix your build issue won't be known until you see what the file actually contains.

like image 144
codelark Avatar answered Nov 10 '22 23:11

codelark


This error occurs when you edit a workbench resource outside of Eclipse. To fix this problem, right click the project or edited resource and select “Refresh”. If you edit outside of Eclipse a lot, you can enable auto-refresh by going to Window->Preferences menu, then in the Preferences dialog box, select General > Workspace. Check the “Refresh automatically” box.

like image 25
SRM Avatar answered Nov 10 '22 23:11

SRM


In Eclipse, if you encounter this issue, there are two common approaches to possibly resolve it.

  1. Select the "Refresh" project just mentioned in other provided answers. (Right click on the project, and then select "Refresh".)

  2. If the "Refresh" does not work, then try to "Clean" the project. (From the menu bar, select "Project" and then select the "Clean..." item. Make sure that you check the current project to clean.)

Normally, these two steps will resolve 90% of the compilation issues -- if the compilation error is not a direct result of some code changes.

like image 28
schang Avatar answered Nov 10 '22 21:11

schang