Reputation: 23
My objective:
Steps I have completed:
Issue Faced:
I am getting a runtime error and there are no comilation errors and the library project is integrated perfectly.
Root Cause:
When I analyzed Logcat, I understand it is due to application name conflict. My main app has an application name as "wish" in its manifest file. The library project in its manifest file also has a name as "Todoapplication"
In the java file there is a line of code as below:
m_app = (TodoApplication) getapplication();
This line throws run time exception because in the main manifest file there is no Todoapplication in the name parameter.
Can anyone, please help me on the situation. Thanks.
Upvotes: 2
Views: 852
Reputation: 1006554
If the library project has a custom Application
class, you will need to inherit from its custom Application class when you define yours. So, have WishApplication extends ToDoApplication
, instead of WishApplication extends Application
.
Note that using a custom Application
is frequently pointless. It has the same effective scope as static data members, and there can only be one Application
object. Hence, I recommend avoiding using a custom Application
class in libraries, as you cannot have two libraries both demanding that the host application use their custom Application
class. And, for your own code, only use a custom Application
class when it is somehow clearly superior to just an ordinary static data member.
Upvotes: 4