Android.mk: Include 3rd party jars

5,688 views
Skip to first unread message

a2ronus

unread,
Apr 27, 2010, 12:13:56 PM4/27/10
to android-platform
Hi android-platform,

I would like to build my MyApp.apk together with the Android platform.
However, the app uses some external jars (commons-codec-1.3.jar,
netty-3.1.5.GA.jar). I cannot find a way to properly include these. In
Eclipse this works fine, but I need to find a way to include these
jars in the Android.mk file.

I have an src, res and lib folder. (The jar files are in the lib
folder.) I have placed the application files in <root-of-android-
source-tree>/packages/apps/MyApp.

Is there some example Android.mk file that I can use? Do I need to put
the jarfiles someplace else?

Any help would be appreciated.

Kind regards,

a2ronus

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

allstars

unread,
Apr 27, 2010, 10:59:36 PM4/27/10
to android-platform
see packages/apps/Calculator Android.mk
see how it uses LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES

thanks

a2ronus

unread,
Apr 28, 2010, 4:43:01 AM4/28/10
to android-platform
Hi allstars,

Thanks a lot! It works now.

For other people that have the same problem: you can find the
Android.mk file from the Calculator app here in the Android source:

http://android.git.kernel.org/?p=platform/packages/apps/Calculator.git;a=blob;f=Android.mk;h=b34c46750bf4c74f8d93a869b919d8fb56a15ab2;hb=HEAD

I've also included most of my Android.mk below.

a2ronus


*** Android.mk ***
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := user

LOCAL_STATIC_JAVA_LIBRARIES := libnetty libcommonscodec

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := AndroidAppName
LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libnetty:lib/
netty-3.1.5.GA.jar libcommonscodec:lib/commons-codec-1.3.jar

include $(BUILD_MULTI_PREBUILT)



On Apr 28, 4:59 am, allstars <allstars....@gmail.com> wrote:
> see packages/apps/Calculator Android.mk
> see how it uses LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES
>
> thanks
>

David Grimfors

unread,
May 4, 2010, 9:26:56 AM5/4/10
to android-platform
I have a similar problem. I have tried this solution (makefile as
below), but it gives me compilation errors because the java compiler
can´t find the classes defined in the jar files.

---------------------------
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := user

LOCAL_STATIC_JAVA_LIBRARIES += libmyjar

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_JNI_SHARED_LIBRARIES := libmylib

LOCAL_PACKAGE_NAME := MyCameraApp
LOCAL_CERTIFICATE := media
include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libmyjar:com.company.jar
include $(BUILD_MULTI_PREBUILT)
------------------------------

If I change
LOCAL_STATIC_JAVA_LIBRARIES += libmyjar
to
LOCAL_JAVA_LIBRARIES += com.company.jar
it compiles, but the jar is not included in the apk.

Any suggestions what might be wrong?

Thanks
David

On 28 Apr, 10:43, a2ronus <a...@theipcompany.nl> wrote:
> Hi allstars,
>
> Thanks a lot! It works now.
>
> For other people that have the same problem: you can find the
> Android.mk file from the Calculator app here in the Android source:
>
> http://android.git.kernel.org/?p=platform/packages/apps/Calculator.gi...

a2ronus

unread,
May 10, 2010, 4:56:21 AM5/10/10
to android-platform
Hi David,

I'm not an Android build system expert, but the only main difference I
can see is that instead of := you use +=. I don't know if different
operators work differently in the Android build system?

Furthermore, what command do you use to build the app? I use something
like: mmm /packages/apps/AndroidAppName (after .build/envsetup.sh and
the lunch command).

Ciao, a2ronus

David Grimfors

unread,
May 11, 2010, 11:07:06 AM5/11/10
to android-platform
That might be the problem then, I used "make MyCameraApp" rather than
"mmm <path to mycameraapp>".
I´ll try that. If it doesn´t work, I´ve made a workaround by editing
the app so it can be build from windows.

Thanks!

//David
Reply all
Reply to author
Forward
0 new messages