working with Android library projects in android build environment

1,146 views
Skip to first unread message

James

unread,
Oct 12, 2010, 10:03:07 PM10/12/10
to Android Building
Hey all,

I have an android library project that my main project compiles
against. In the past, I used ant but I want it to be compiled with
the rest of my custom ROM when I build...its in packages/apps/MyApp
and packages/apps/MyAppLib ... how do I tell MyApp to use MyAppLib in
the Android.mk file?

Thanks,
James

p.s. I'm referring to the type of library project discussed here:
http://developer.android.com/guide/developing/other-ide.html#libraryProject

Ying Wang

unread,
Oct 13, 2010, 2:02:18 PM10/13/10
to android-...@googlegroups.com
First in packages/apps/MyAppLib/Android.mk you define your library module, which I believe should be a static java library.
Then reference it in your MyApp's Android.mk by LOCAL_STATIC_JAVA_LIBRARIES.
See http://source.android.com/porting/build_cookbook.html

--
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

James Fitzgerald

unread,
Oct 13, 2010, 3:00:28 PM10/13/10
to android-...@googlegroups.com
Hey Ying,

Thanks for your reply.  When I do that, I get "package R does not exist" errors because it doesn't compile the resources in my Android Library.  Here is my Android.mk:

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

  # Build all java files in the java subdirectory
  LOCAL_SRC_FILES := $(call all-java-files-under, src)

  LOCAL_MODULE := MyAppLib
  include $(BUILD_STATIC_JAVA_LIBRARY)

Thanks,
James

Ying Wang

unread,
Oct 13, 2010, 4:40:54 PM10/13/10
to android-...@googlegroups.com
We are not able to put resources into a library yet...
You have to move the resource into your apps' project.

George Lezhava

unread,
Jul 12, 2013, 11:24:52 AM7/12/13
to android-...@googlegroups.com
Have not tried the solution myself, but it looks like the way to go. In AOSP, there are two interesting projects:
packages/apps/Email and frameworks/ex/chips. The latter being used as an Android library for the first one. 
Take a look in their Android.mk build files for details. The trick is LOCAL_AAPT_FLAGS and referencing /chips/res folder in the build of the Email project.
Good luck with trying though

GG

unread,
Sep 21, 2014, 6:28:00 AM9/21/14
to android-...@googlegroups.com
It works perfectly
Reply all
Reply to author
Forward
0 new messages