How to add new java library to Android

1,878 views
Skip to first unread message

RupaSunita n

unread,
Nov 2, 2010, 11:08:02 PM11/2/10
to android-...@googlegroups.com
Hi,

I'm adding a new java library to my froyo system;
In order  to isolate my changes from the Android framework classes, i'm compiling the new library as a separate java lib.
Here the issue is, i'm not able to link the new lib to any of the Android system classes eg: android.view, android.utils etc........

Here is the Android.mk file for the new java library. Please suggest me on what is missing in my make file for new library to access Android system libraries:

LOCAL_PATH := $(call my-dir)

# the library
# ============================================================
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_NO_STANDARD_LIBRARIES := true

LOCAL_JAVA_LIBRARIES := core framework  --> this is not taking effect????

# This is the target being built.
LOCAL_MODULE:= omap_mm_runtime_library

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


include $(BUILD_JAVA_LIBRARY)

Thanks for your help.

Regards,
Sunita.

Dianne Hackborn

unread,
Nov 2, 2010, 11:23:20 PM11/2/10
to android-...@googlegroups.com
You can't use a new shared library from the framework.  That would require pulling the library in to the boot class path, polluting the namespace for all apps.

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



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

RupaSunita n

unread,
Nov 3, 2010, 9:56:26 AM11/3/10
to android-...@googlegroups.com
Thanks Dianne HackBorn.
My issue is that, i'm not able to make use of any of the system classes in my new java library.

eg: i wanted to use android.view in my new java class
import android.view

but the compiler throws error: "package android.view" doesn't exist

and one important point is that, i'm not compiling my java class as an apk, im building a java library using BUILD_JAVA_LIBRARY.

Thanks & Regards,
sunita.

Ying Wang

unread,
Nov 3, 2010, 5:33:33 PM11/3/10
to android-...@googlegroups.com
On Tue, Nov 2, 2010 at 8:08 PM, RupaSunita n <rupasu...@gmail.com> wrote:
Hi,

I'm adding a new java library to my froyo system;
In order  to isolate my changes from the Android framework classes, i'm compiling the new library as a separate java lib.
Here the issue is, i'm not able to link the new lib to any of the Android system classes eg: android.view, android.utils etc........

Here is the Android.mk file for the new java library. Please suggest me on what is missing in my make file for new library to access Android system libraries:

LOCAL_PATH := $(call my-dir)

# the library
# ============================================================
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_NO_STANDARD_LIBRARIES := true
Remove the above line. 

LOCAL_JAVA_LIBRARIES := core framework  --> this is not taking effect????
You don't need to add the standard libraries by yourself. 

# This is the target being built.
LOCAL_MODULE:= omap_mm_runtime_library

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


include $(BUILD_JAVA_LIBRARY)

Thanks for your help.

Regards,
Sunita.

--

RupaSunita n

unread,
Nov 3, 2010, 5:42:33 PM11/3/10
to android-...@googlegroups.com
Hi Ying Wang,
Thanks a lot.
that is what i started with initially and added other two.
now once again i tried removing those two lines, but i see the same issue.

Regards,
Sunita.

Ying Wang

unread,
Nov 3, 2010, 6:48:51 PM11/3/10
to android-...@googlegroups.com
Run "make showcommands omap_mm_runtime_library" and send me the log.

RupaSunita n

unread,
Nov 3, 2010, 8:26:12 PM11/3/10
to android-...@googlegroups.com
Hi Ying Wang,

Please find the log below. this time it is throwing error from the framework which is using my lib.

Froyo1$ make showcommands omap_mm_runtime_library
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2.1
TARGET_PRODUCT=blaze
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=MASTER
============================================
Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-full-debug.jar
out/host/linux-x86/bin/acp -fpt out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-full-debug.jar out/target/common/obj/JAVA_LIBRARIES/core_intermediates/emma_out/lib/classes-full-debug.jar
Install: out/host/linux-x86/framework/dx.jar
out/host/linux-x86/bin/acp -fpt out/host/common/obj/JAVA_LIBRARIES/dx_intermediates/javalib.jar out/host/linux-x86/framework/dx.jar
Install: out/host/linux-x86/bin/dx
out/host/linux-x86/bin/acp -fpt out/host/linux-x86/obj/EXECUTABLES/dx_intermediates/dx out/host/linux-x86/bin/dx
Install: out/host/linux-x86/bin/aapt
out/host/linux-x86/bin/acp -fpt out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt out/host/linux-x86/bin/aapt
Copying: out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-full-debug.jar
out/host/linux-x86/bin/acp -fpt out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-full-debug.jar out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/emma_out/lib/classes-full-debug.jar
Install: out/host/linux-x86/bin/aidl
out/host/linux-x86/bin/acp -fpt out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl out/host/linux-x86/bin/aidl
make: Circular out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar <- out/target/common/obj/JAVA_LIBRARIES/omap_mm_runtime_library_intermediates/javalib.jar dependency dropped.
target Java: framework (out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes)
rm -f out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar
rm -rf out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes
mkdir -p out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes
for f in ; do if [ ! -f $f ]; then echo Missing file $f; exit 1; fi; unzip -qo $f -d  out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes; (cd  out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes && rm -rf META-INF); done
if [ -d "out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src" ]; then find out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src -name '*.java' >> out/target/common/obj/JAVA_LIBRARIES/framework_intermediates//java-source-list; fi
tr ' ' '\n' < out/target/common/obj/JAVA_LIBRARIES/framework_intermediates//java-source-list | sort -u > out/target/common/obj/JAVA_LIBRARIES/framework_intermediates//java-source-list-uniq
javac -J-Xmx512M -target 1.5 -Xmaxerrs 9999999 -encoding ascii -bootclasspath out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar -classpath out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/omap_mm_runtime_library_intermediates/classes.jar  -g  -extdirs "" -d out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes \@out/target/common/obj/JAVA_LIBRARIES/framework_intermediates//java-source-list-uniq || ( rm -rf out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes ; exit 41 )
frameworks/base/core/java/android/widget/VideoView.java:52: package com.ti.omap.omap_mm_runtime_library does not exist
import com.ti.omap.omap_mm_runtime_library.OmapMMRuntimeLibrary;
                                           ^
frameworks/base/core/java/android/widget/VideoView.java:65: cannot find symbol
symbol  : class OmapMMRuntimeLibrary
location: class android.widget.VideoView
    private OmapMMRuntimeLibrary omapMMHandle = new OmapMMRuntimeLibrary();
            ^
frameworks/base/core/java/android/widget/VideoView.java:65: cannot find symbol
symbol  : class OmapMMRuntimeLibrary
location: class android.widget.VideoView
    private OmapMMRuntimeLibrary omapMMHandle = new OmapMMRuntimeLibrary();
                                                    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] Error 41


Thanks & regards,
Sunita.

Ying Wang

unread,
Nov 3, 2010, 9:04:28 PM11/3/10
to android-...@googlegroups.com
You also changed the framework library and reference your custom library from there? then from the build system's perspective, there are cyclic dependency and it certainly won't work.
As Dianne pointed out, you can not add new dependency library to framework.

RupaSunita n

unread,
Nov 3, 2010, 9:44:45 PM11/3/10
to android-...@googlegroups.com
Thanks Ying Wang.
So, if i want to extend frameworks functionality to talk to my native code (rather than from .apk), what is the suggested approach?
Here my intension is to extend VideoView to talk to my native code via custom JNI.
Please suggest the best way to handle this,

Thanks & Regards,
Sunita.

Ying Wang

unread,
Nov 3, 2010, 10:39:02 PM11/3/10
to android-...@googlegroups.com
sorry, I don't know much about it.
I am also curious about the best way to do that. Maybe Dianne can give some suggestion?

Dianne Hackborn

unread,
Nov 3, 2010, 11:20:01 PM11/3/10
to android-...@googlegroups.com
If you are modifying how the framework works, you will need to make changes to it.  So make your changes.  You'll want to just build them in to the framework.  Keep them as small as possible, to reduce both the impact you have and the effort you have in maintaining them as you rebase on future versions of the framework.

If you are introducing new classes, be sure to put them in a namespace you own so you can guarantee they will never appear in an app.

RupaSunita n

unread,
Nov 4, 2010, 10:30:07 AM11/4/10
to android-...@googlegroups.com
Hi Dianne,

Thanks for suggestions.
I'm not including my new classes under android name space.
So, is it okay if i add new classes and build them in my own name space as a separate package and link them to android classes?
is this linking acceptable??

Regards,
Sunita.
Reply all
Reply to author
Forward
0 new messages