Android: Including multiple Java Packages to Manifest

Viewed 47939

The app I am developing has many activities organized into seven java packages. Originally I wrote all the coding and stuff for each group of activities in a java package as different projects.

Now I'm at the point where I want to put all the packages together into one project. When I add a new package to the src folder, I get an error for all my R.id.* values ("R cannot be resolved").

My instinct tells me that there is something fancy I have to put in the project manifest, but I can't find any resource online to tell me how.

(Note: I have read this and this and I still couldn't figure out how to add additional packages to my project.)

5 Answers

Check that the layout -> main.xml file is correct and includes the android:id="@+id/whateverIdHasCausedYouTheError"

The R.java file will then be updated to include the id.. and bam, your error should disappear.

I am using APK Builder and all xml resources are declared in an auto generated java file by aapt. Its package name is you guess, the android manifest package name.

Then it dawned on me that xml files dont have package names. All xml files are just xml files. Then aapt generates an R class with all XML resources in one R class. The package name of this class is the one in the manifest.

So either import package-name.R or just use one package for your entire project.

Related