How To Use My Custom Library Apk File In Other Applications
Solution 1:
The <uses-library>
element is for add-ons supplied as extensions to the firmware. AFAIK, it will not be usable for your scenario.
Most likely, you will need to implement a service that exposes an API via AIDL, or uses a set of documented Intent
actions to exchange data with other applications, or exposes a ContentProvider
.
Otherwise, package your code as a JAR, not an APK. You can see many examples of this in my github repositories (all of the cwac- ones follow this pattern).
Solution 2:
When converting from a jar library to and apk library make sure that the reference to the jar is removed from "Java Build Path" -> "Projects" and the library is added to "Android" -> "Library".
Solution 3:
I try to use a jar library in eclipse (I added an external jar library in the Java Build Path options of my project). The application compiles but I have a "Could not find class..." exception at runtime.
Solution 4:
You can actually make a project that links to another project.
You have to do two things in Eclipse:
- add uses-library = package name in the manifest.xml
- open project properties -> Java Build Path -> Projects and add the project of the used library
But i haven't managed to make it run. The sdk correcly uploads both packages, but I get an link error
WARN/dalvikvm(444): Link ofclass'Lme/guillaumin/android/osmtracker/activity/DisplayTrackMap;' failedERROR/dalvikvm(444): Could not find class'me.guillaumin.android.osmtracker.activity.DisplayTrackMap', referenced from method me.guillaumin.android.osmtracker.activity.TrackLogger.onOptionsItemSelected
WARN/dalvikvm(444): VFY: unable to resolve const-class154 (Lme/guillaumin/android/osmtracker/activity/DisplayTrackMap;) in Lme/guillaumin/android/osmtracker/activity/TrackLogger;
The VM cannot load the class in my app that links into the libs app.
Solution 5:
The lib.apk "application" should publish intents using Intent-Filters
in the AndroidManifest.xml file.
The activity which requires to use the activity within the lib.apk, just needs to start an intent like below :
Intent i = newIntent();
i.setClass(this, libAPKActivity.class);
Post a Comment for "How To Use My Custom Library Apk File In Other Applications"