HappyGeisha HappyGeisha - 1 year ago 107
Android Question

Android: Including multiple Java Packages to Manifest

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.)

Answer Source

Make sure that the import statement at the top of the Activity references the correct R file. Each project has its own R file, so if you copy an Activity from one project to another it will still be trying to reference the R file from the old project.

You do not need any explicit inclusion of different packages in the manifest. To include activities from two different packages, say:


you can do the following:

<manifest package="com.example" . . . >
  <application . . .>
    <activity android:name=".package1.Activity1" . . . />
    <activity android:name=".package2.Activity2" . . . />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download