Reputation: 3952
The first package is com.first.one and the second one is com.second.two
Both the packages use the same xml files..
My problem is that my code in the first package works fine but the second package doen't..
I think the problem should be in the manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.first.one"
android:versionCode="1"
android:versionName="1.0" >
As only the first package com.first.one is used and the second is not used. if that is the problem. How can I declare both the packages in manifest?
If this is not the problem then why doesn't my code in the second package work?
Upvotes: 2
Views: 10724
Reputation: 439
I think you want to have two app . you can use a build file that allows you to change package name in the manifest
target
<target name="name1_2" depends="">
<replaceregexp file="AndroidManifest.xml" match='com.first.one' replace='com.first.second' byline="true" />
</target>
<target name="name2_1" depends="">
<replaceregexp file="AndroidManifest.xml" match='com.first.second' replace='com.first.one' byline="true" />
</target>
Upvotes: 2
Reputation: 110
The idea behind having separate packages is that secondary package(s) should supplement your application. For example, if you are writing an application that is to use a website API, you could keep that package, say com.websiteAPI and draw from its resources as necessary, by importing:
import com.package_name_requested_here.R.*
Another example would be to write a package specifically for global objects, say com.objects.
To contrast this, your own package (the one specified in the manifest) should contain any and all files that are specific to your application. Remember that you can set up the package to include subpackages though. For example, if you made:
package="com.mystuff"
You could reference your activities in the manifest by writing:
<activity android:name=".first.one" </activity>
<activity android:name=".second.two" </activity>
Hope this helps. ^_^
Upvotes: 2
Reputation: 82533
This is not possible. Instead, you can add import com.first.one.R.*;
to the classes in the second package to allow them to use the same same resources as the first one.
Upvotes: 2