How to reference a 3rd part jar with resource files in android.mk?

1,180 views
Skip to first unread message

BenKwan

unread,
Aug 23, 2011, 3:02:41 AM8/23/11
to Android Building
I modified the Launcher app and it depends on a 3rd part jar library
with some resource(e.g. image and font). The resource is used by the
3rd part jar library(e.g LibClass.class.getResource("icon.png") ).

If i build the launcher app with eclipse through: adding
<classpathentry kind="lib" path="lib/3rd-part.jar"/>. The 3rd part jar
lib is build into dex file and eclipse seems preserving resources file
in the 3rd-part jar into a folder in the apk:
APK:
--com (this folder maps the resources in the 3rd part jar)
--res
--META-INF
--AndroidManifest.xml
--classes.dex
--resources.arsc

And the application works.

But when add my changes to android source codes, i modify the
android.mk in packages/apps/launcher2 like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_JAVA_LIBRARIES := android-common\
3rd-part

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := Launcher2
LOCAL_CERTIFICATE := shared

LOCAL_OVERRIDES_PACKAGES := Home

LOCAL_PROGUARD_FLAG_FILES := proguard.flags


include $(BUILD_PACKAGE)


#########################################

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := 3rd-part:lib/3rd-part.jar

include $(BUILD_MULTI_PREBUILT)


now the jar lib is built into the classes.dex in apk. but there is no
com folder in the apk, and because andorid can't read resources from
jar, the app will be crash because the 3rd-part lib's codes can't get
the resouces?

how can i do the same thing with the eclipse adt did?

by the way, i have made some tests using library project, it also
works, but it need the sources code of the 3rd-part library.

could anybody give some comments?

Thx a lot.

Ying Wang

unread,
Feb 4, 2013, 3:38:33 PM2/4/13
to android-...@googlegroups.com
Previously the build system didn't support to merge Java resources from a static library.
To work around, you'll need extract the resource dir out from the jar and put it in the source tree, 
then in the app's Android.mk use this:
LOCAL_JAVA_RESOURCE_DIRS += <resource dir path relative to the LOCAL_PATH>

But in the master build system, it supports auto-merging Java resource carried by a static library now.

On Sat, Feb 2, 2013 at 5:05 AM, Yongyi Li <lyy...@gmail.com> wrote:
Hi, BenKwan,
   I encounter the same issue, have you resolved it ? Thank you:)

在 2011年8月23日星期二UTC+8下午3时02分41秒,BenKwan写道:

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages