"AndroidManifest.xml error does not declare Java package"

It may be a Linux error rather than a programming error, but I'm not sure. AndroidManifest.xml is somewhat Greek for me. Nevertheless, my program compiled and launched the current state in it completely normal, it is even on the market. About a month has passed since I opened the source in Eclipse, and today, when I opened it, he refused to compile and display 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 name of the package (and the directory in which it is located). I confirmed that the file works fine in a text editor and even updated it in Eclipse. Nothing.

I updated ADT ... maybe the criteria for AndroidManifest.xml have 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> 
+7
android
source share
6 answers

This exception is not related to Android:

[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: the resource is not synchronized with the file system: '/XXX/AndroidManifest.xml'.

This means that the file loaded in the Eclipse editor does not match the file on the file system.

Click a resource (or even better, an eclipse project) in the browser or package view, right-click and select Update.

Whether this will completely fix your build problem is not known until you see what the file actually contains.

+21
source share

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

+12
source share

In Eclipse, if you run into this problem, there are two common approaches that can solve it.

  • Select the Refresh project just mentioned in the other answers provided. (Right-click on the project and select Refresh.)

  • If Refresh doesn’t work, try a Clean project. (In the menu bar, select “Project”, then select “Clear ...”. Make sure that you check the current project for cleaning.)

Typically, these two steps solve 90% of the compilation problems — unless the compilation error is a direct result of some code changes.

+2
source share

I had this exact problem, and updating the project worked like a charm.

0
source share

You may also get this error: eclipse when you try to import an AndroidStudio-based project into your eclipse development environment.

If so, there is no point in updating. You should rearrange all files with Java forlder to the src folder ... (Time to switch to Android Studio, I think)

0
source share

No answer helped me. My manifest file is missing an attribute package and therefore it gave this error.

I added this attribute using the following code snippet and it worked after the update.

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp" > 
0
source share

All Articles