1

I am working with a library project which internally contains .JAR files and my code as well.

I want to have a single JAR file for all the project(including drawables). I was able to do it with the help of FatJar plugin with eclipse. I have called resources as R.drawable.icon in JAR file code.

Now the question is I want to use these drawables in creating a notification.

For example:

Notification notification = new Notification(icon, tickerText, when); 

Here icon is a integer ID must be in JAR file itself. I do not want drawable to be in my Application that will use that library.

I have seen this post from Packaging drawable resources with a JAR? But unable to depict any solution.

Please provide any suggestions on the same.

Thanks.

2 Answers 2

1

You cannot package Android resources in a JAR.

You are welcome to switch to the work-in-progress Gradle-based build system and package your library as an AAR file, which can contain resources.

Sign up to request clarification or add additional context in comments.

5 Comments

I have added a res folder in a runnable JAR with FatJar plugin in eclipse. I am having a problem of calling them. If i extract the JAR,I can see all the resources. But there is no .R file from where i can use them.If i use the project as library project everything works well.
@PrabhjotSingh: That is because you cannot package Android resources in a JAR.
It is a Runnable JAR.I am looking for any solution that can work.
@PrabhjotSingh: "It is a Runnable JAR" -- there is no such concept in Android application development. "I am looking for any solution that can work" -- you are welcome to switch to the work-in-progress Gradle-based build system and package your library as an AAR file, which can contain resources. Or, ship the resources along with the JAR in a binary-only Android library project (as Google does with the Play Services SDK).
Thanks for the help. I will look for packaging the project as "AAR file" as provided in the link.
0

I can suggest you read J.J. Kim's answer here. I think this is what you want. Please take note that this is a hack (a neat one)

Packaging Android resource files within a distributable Jar file

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.