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?
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.
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" />
Related
Basically I am developing an android app. Icreated a new library project and generated the aar file. Next in my main project I imported the aar file, added dependecy in my main project app module. Everything is fine till this point.
I wanted to use an activity instance of the aar library into my main project. So I added
<uses-library android:name="com.mylibray.project" android:required="true" />
in the main android manifest.
While installing it in android device/emulator getting INSTALL_FAILED_MISSING_SHARED_LIBRARY error. How to solve this?
I have solved this problem by using Google APIS/Intel Atom x86 as CPU in the emulator, without Google APIS I always get that error you said. ;)
I am working on a project , where i need to render pdf on my device screen.
For that i am using mupdf library.
I have included it in my project.
Now from library project , i need to use MuPDFActivity.class through intent for showing pdf.
But i am getting activitynotfound exception.
I have tried of including library's activity in my manifest.
<activity
android:name="com.example.xrgpc.mupdf.MuPDFActivity"
android:label="#string/app_name">
</activity>
But i am getting same error.
Will some one guide me what's i am doing wrong.
check your library minSdk, if your library minSdk smaller then app you can not declaring at AndroidManifest.xml
And change if you import appcompat Activity to AppCompatActivity
I am looking to use the android sample project 'Bluetooth chat' as a library so that I can use it inside another application.
I have marked the project as a library in its properties and I have referenced the project in my application. I understand I need to update my applications manifest file, however I am totally lost as to what needs to be added/changed(I am a total beginner).
I am just looking to launch the sample from the click of a button within my application.
I have read the documentation about referencing but I am still pretty confused. Any guidance would be much appreciated!
if you access your project you enter your manifest file for entry lie that
<activity
android:name="<Package name>.<java file name>"
/>
Make Sure your lib and your project in same folder.
The task is very simple but I can't find any solution.
I have an application which is based on my Android Library Project.
Activities are not defined in my main app but in the library project.
Eclipse doesn't allow me reference my library project from the test project targeted to main app.
Is there a working example to see how it is done?
If you want to use activity from Library Project, and you already attached it as library to build path, than you need also to put targeted activity in android manifest.
<activity android:name="com.packageInWhichActivityIs.activityName"></activity>
I`m assuming that you are getting class not found exception. Next time please provide more specific information.
I have created a project as library that uses MapActivity but when it is referenced in another project it cannot link with that project. But if the same project is used with only Activity then everything works properly. The project is linked properly and the activity of the library gets called from other project.
The error that shows up in the logcat is Unable to resolve superclass of packagename/SampleLibActivity; (13)
I really do not understand the reason of error only when extending with MapActivity. Are there any limitations with creating library project?
Have add the key generated from google maps in the new project?
I did a silly mistake of not including uses-library inside application tag.
Hope this helps out someone else too.