Reputation: 7238
I am trying to fork my android app, and came upon a method thanks to my other question here using a library project. It is working fine enough for drawables and String assets. But now I've run into a problem.
I have a class (not an activity) which extends Application
. I moved this class into my library project, and want to use it for the main application class in my two derived apps (works fine when directly in the main app).
Say my library is my.project.library
and my app using the library is my.project
In the manifest for my.project
I specified the following:
<application android:name="my.project.library.AppClass">
It compiles and deploys fine, but when I try to run it, it force-closes with the following exception:
11-15 03:14:25.707: E/AndroidRuntime(16800): java.lang.RuntimeException: Unable to instantiate application my.project.library.AppClass: java.lang.ClassNotFoundException: my.project.library.AppClass in loader dalvik.system.PathClassLoader[/data/app/my.project.apk]
From the drawables I also imported from the library, it seems that the library contents get in-lined into the main app. So I tried changing my manifest to:
<application android:name="my.project.AppClass">
but I still get the same error.
How can i reference a class in the library as my Application class in the main app?
Upvotes: 1
Views: 3834
Reputation: 5156
Your original reference was correct.
That is:
<application android:name="my.project.library.AppClass">
Sounds like you not referencing the library project properly see http://developer.android.com/guide/developing/projects/projects-eclipse.html the Referencing a Library Project section.
Upvotes: 1
Reputation: 5157
I think you have not described the library that you are using in the manifest so you need to add something like this to the manifest.
<uses-library android:name="my.project.library" />
Upvotes: 1