Question

I'm trying to use a png file in my jar using getClass().getResourceAsStream("mypngfile.png")

I tried many things found on the internet but nothing helped. I think the issue is that the png is not included in my jar. I'm using a full android build and when going into out/target/common/obj/JAVA_LIBRARIES/myjarname_intermediates/classes/my/package/.. It looks like all my classes are there except for the png.

I also tried opening the jar in eclipse and using tar -tvf but i couldn't even see the classes there. Probably has to do with the way android compiles the jars without the code itself?

I think I need to change my Android.mk file somehow so that the png is compiled and added to the build.

my android.mk looks like this:

include $(CLEAR_VARS)

LOCAL_SRC_FILES := src/files...  \
                   src/my/package/pen.png 


LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES  := src/my/package/pen.png \
                           res/drawable-xhdpi/pen.png 
LOCAL_MODULE := MyLibName

include $(BUILD_JAVA_LIBRARY)`

How do I change the android.mk so that the png is compiled and inserted into the jar?

Was it helpful?

Solution

I found the solution here: https://groups.google.com/forum/#%21topic/android-building/w8P7GyT5YjE

I needed to add LOCAL_JAVA_RESOURCE_DIRS := with the resources directories to my png files and they are finally packaged with the jar file!

hope this helps everyone else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top