Creating a Library JAR for Android Applications

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Creating a Library JAR for Android Applications

Postby rubixcube88 » Thu Sep 24, 2009 12:06 am

I want to create a library to be included with other application projects, but there I am running into a problem with resource management. It seems like whenever an application is packaged with the Android SDK, a new R class is created with ONLY what is in the current application's res/ directory. So I have my res/ directory with all my resources for my library which are then put into the resulting .jar. However, when I include this .jar in another Android application project, the resources in the final .apk do not include anything from my library resources; that .apk package only contains the resources in the actual Android application project, ignoring everything in the libs/*.jar files. Furthermore, the indices generated in the resulting R class for the application (not my library) start at the same index. This means that when I reference something such as R.string.<something>, I will actually end up referencing the application package's resources instead of my own library resources.

Is there any way for me to have localizable resources in my library project, without having to touch the application project's resources? ANY information would be greatly appreciated!!!

Thank you
Posts: 5
Joined: Wed Sep 23, 2009 11:50 pm


Postby azraeal » Wed Sep 30, 2009 1:50 am

There is no known method to include resources in a jar package. Sorry to break the bad news.
Experienced Developer
Experienced Developer
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

you can do it

Postby r.raviprakash » Mon Dec 07, 2009 10:01 am

manifest file of both application should have same package and copy the resource in your current application will solve the issue.

<manifest xmlns:android=""

Please let me know if you need more clarifications.
Once Poster
Once Poster
Posts: 1
Joined: Mon Dec 07, 2009 9:56 am


Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 5 guests