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.

3
  • 1
    your scenario is like "ApplicationLib1 extends Application" , "ApplicationLib2 extends Application" and "YourApplication extends Application" ? Commented Sep 25, 2013 at 10:08
  • You need to implement Multilevel inheritance to resolve this scenario. Commented Sep 25, 2013 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! Commented Jun 20, 2014 at 13:11

2 Answers 2

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"
 >
Sign up to request clarification or add additional context in comments.

5 Comments

how can i use lib2Application class.. please give me an example?
Some times you will need to implement it in several places in The Manifest: <application android:name="com.example.MyAppClass" android:allowBackup="true"> <activity android:name="com.example.MyAppClass" android:configChanges="locale" android:label="MyAppClass" > <action android:name="com.example.MyAppClass" /> </activity>
And what we can do if libraries were jar?! In this case we can't write something like this: public Lib2Application extends Lib1Application !
@ Mr.Hyde your point is very nice. Need some more steps to make it work even it is inside .jar files. Just create a separate question and get me the link for that.
@BirajZalavadia Please look at stackoverflow.com/questions/24452509
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.