Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to declare two packages with their activities in android manifest file?

I have two packages in my android application. How to mention those different packages along with their activities in android manifest file?In my code I have given as

<manifest package="com.tabwidget">
    <application>
        <activity android:name=".com.tabwidget.Tab"></activity>
        <activity android:name=".com.tabwidget.TabHostProvider"></activity>
        <activity android:name=".com.tabwidget.TabView"></activity>
    </application>
</manifest>                  
<manifest package="com.kpbird.tabbarcontrol">
    <application>
        <activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
    </application>
</manifest>

But I am getting exception Unable to find explicit activity class ...........Where was i wrong? Please help me...........

like image 725
hemanth kumar Avatar asked Aug 23 '11 11:08

hemanth kumar


People also ask

How do I declare an activity in manifest XML?

Declaring an activity is a simple matter of declaring the <activity> element and specifying the name of the activity class with the android:name attribute. By adding the <activity> element to the Android Manifest, we are specifying our intention to include this component in our application.

Which tag is used to declare an activity in the manifest file?

Element Tags of Manifest File It consists of a package attribute package that tells the activity's package name. It is the subelement of the manifest file that includes the declaration of the namespace. It contains certain attributes.

What is the right way to declare package in Android?

Right click on the project and choose new => "package". You may need to update your references to other classes once reorganised.


2 Answers

It seems you have made a few mistakes in the XML:

<manifest package="com.tabwidget">
    <application>

        1) BELOW: starting the names by "." means that
        you are implicitely extending the package prefix defined in the package 
        attribute of the manifest XML tag. 
        For example, if your package is "com.tabwidget", defining".MyActivity"
        will be interpreted as "com.tabwidget.MyActivity"
        By removing the first ".", you use an explicit notation instead:
        whatever your package is, "com.tabwidget.MyActivity" is interpreted
        as "com.tabwidget.MyActivity"
        <activity android:name=".com.tabwidget.Tab"></activity>
        <activity android:name=".com.tabwidget.TabHostProvider"></activity>
        <activity android:name=".com.tabwidget.TabView"></activity>
    </application>
</manifest>                  

2) BELOW: a manifest file should only contain one manifest XML tag:
<manifest package="com.kpbird.tabbarcontrol">
    <application>

        3) BELOW: same mistake as 1)
        <activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
    </application>
</manifest>

What follows should work. It fixes these 3 mistakes:

<manifest package="com.kpbird.tabbarcontrol">
    <application>
        <activity android:name="com.tabwidget.Tab"></activity>
        <activity android:name="com.tabwidget.TabHostProvider"></activity>
        <activity android:name="com.tabwidget.TabView"></activity>
        <activity android:name=".TabbarView"></activity>
    </application>
</manifest>
like image 167
Shlublu Avatar answered Sep 18 '22 21:09

Shlublu


you can do like this . you need no to do any explicit inclusion of different package

<manifest package="com.tabwidget">
<application>
    <activity android:name="com.tabwidget.Tab"></activity>
    <activity android:name="com.tabwidget.TabHostProvider"></activity>
    <activity android:name="com.tabwidget.TabView"></activity>
    <activity android:name="com.tabwidget.TabbarView"></activity>
</application>

like image 27
Rajeev Kashyap Avatar answered Sep 20 '22 21:09

Rajeev Kashyap