31

I am developing a native android application, in which I am trying to use 2 open-source libraries. Problem is both the libraries are using Application Class in their respective libraries. They are registering these classes in their respective source code in manifest file using "android:name" under the application tag. Question is how to handle such a scenario, since as we know, only ONE tag can be used inside manifest file. Can we register/instantiate the Application Class in the code, so that we mention only ONE library in tag and the second using code/pragmatically. OR are there any other alternatives. Please share your comments/suggestions. Thanks in advance.

user2072344
  • 465
  • 1
  • 5
  • 8
  • 1
    your scenario is like "ApplicationLib1 extends Application" , "ApplicationLib2 extends Application" and "YourApplication extends Application" ? – Biraj Zalavadia Sep 25 '13 at 10:08
  • You need to implement Multilevel inheritance to resolve this scenario. – Biraj Zalavadia Sep 25 '13 at 10:13
  • 2
    @BirajZalavadia And what we can do if libraries were jar?! In this case we can't write something like this: public Lib2Application extends Lib1Application! – Dr.jacky Jun 20 '14 at 13:11

2 Answers2

56

You need to implement Multilevel inheritance to resolve this scenario.

This is your scenario

public Lib1Application extends Application{

}

public Lib2Application extends Application{

}

public YourApplication extends Application{

}

How to resolve this?

public Lib1Application extends Application{

    }

    public Lib2Application extends Lib1Application{

    }

    public YourApplication extends Lib2Application{

    }

finally in mainfest.xml

<application
        android:name="com.your.packagename.YourApplication"
        android:icon="@drawable/ijoomer_luncher_icon"
        android:label="@string/app_name"
 >
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
1

Only the manifest and application elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful. See this link: http://developer.android.com/guide/topics/manifest/manifest-intro.html#filec