I am trying to build an application and an interface jar using the android build system in Linux My application has a dependency with my interface, hence I have to make interface jar ready before application make.
But we faced build/run time issues while using our newly built interface jar. I have tried to make the application in two different sequence.
Case 1. Building the interface as local module and linking it with apk as LOCAL_JAVA_LIBRARIES. Case 2. Building the interface as local module and linking it with apk as LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES.
Following are the Android.mk files for main and interface.
1.Main Andriod.mk file: /source/Android.mk
=======================================
STACK_PATH:= $(call my-dir)
LOCAL_PATH := $(STACK_PATH)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/interface/Android.mk
include $(CLEAR_VARS)
LOCAL_PATH := $(STACK_PATH)
include $(LOCAL_PATH)/application/Android.mk
=======================================
2.Interface Android.mk : /source/interface/Android.mk
=======================================
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files, src)
LOCAL_MODULE := MyInterface
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_JAVA_RESOURCE_DIRS := src
include $(BUILD_JAVA_LIBRARY)
$(call dist-for-goals, droidcore, $(full_classes_jar):MyInterface.jar)
=======================================
Following are the Android.mk files for application in CASE 1.
Application Android.mk: /source/application/Android.mk
=======================================
TOP_LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := MyApplication
LOCAL_JAVA_LIBRARIES := MyInterface
include $(BUILD_PACKAGE)
include $(BUILD_MULTI_PREBUILT)
=======================================
Build completed successfully .But when trying to run this application, it shows this error. I/dalvikvm( XXXX): Failed resolving Lcom/test/example/application; interface XXX 'Lcom/test/example/interface;' W/dalvikvm( XXXX): Link of class 'Lcom/test/example/application;' failed
Following are the Android.mk files for application in CASE 2.
Application Android.mk /source/application/Android.mk
=======================================
TOP_LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
$(shell (cp $(LOCAL_PATH)/../out/target/common/obj/JAVA_LIBRARIES/Interface_intermediates/classes-jarjar.jar $(LOCAL_PATH)/applications/libs/MyInterface.jar ))
LOCAL_STATIC_JAVA_LIBRARIES += MyInterface
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := MyApplicationss
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += MyInterface:libs/MyInterface.jar
include $(BUILD_PACKAGE)
include $(BUILD_MULTI_PREBUILT)
=======================================
This resulted in a build error as follows.
build/core/base_rules.mk:166: * source/applications: MODULE.TARGET.JAVA_LIBRARIES.MyInterface already defined by source/interface. Stop.
But when they are built seperately without using the build system, this problem is not there.Also the application runs without error.
When the interface was built to Myinterface.jar using the eclipse, and build the application-apk using this interface jar(by linking statically) in Linux, the application ran smoothly.
Is there any issue in my Android.mk files? Please help