I want to add some features into Browser app by start an activity from another android application. It gives me package does not exist while I make the Main Pro
I know I'm digging this out of the grave a little bit, but there was never really an answer for how to actually include an Android Library Project (or other apk with resources) within an AOSP built application.
Here is what I have done with two projects. "main" is the main application I am building the apk for. "util" is a utility library with resources I am linking against. Both of the projects reside in external/seabold/{package}:
Android.mk in seabold/
LOCAL_PATH := $(call my-dir)
UTIL_PATH := $(LOCAL_PATH)/util
UTIL_JAVA_SRC := $(call all-java-files-under, util/src)
#Filter out if the util library isn't present
UTIL_RES_DIR := $(wildcard $(UTIL_PATH)/res)
include $(call all-subdir-makefiles)
Android.mk in seabold/main/
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := main
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
#Since the BUILD_PACKAGE makefile expects java files to be relative paths,
#we need to add the ../ in front of each file (which is stored as relative
#to seabold/
LOCAL_SRC_FILES += $(patsubst %.java,../%.java,$(UTIL_JAVA_SRC))
#Make sure both packages' resources are included
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res $(UTIL_RES_DIR)
#Since we are including resouces for two packages (This app and the util lib),
#we need to tell aapt to generate an R.java for the util package as well
LOCAL_AAPT_FLAGS := --generate-dependencies --extra-packages com.seabold.util --auto-add-overlay
include $(BUILD_PACKAGE)
Be careful here to make sure you fiddle with the filenames correctly. For me, the files defined in UTIL_JAVA_SRC are in the form of util/src/com/seabold/util/*.java. Since, the build script for the main app expects java files to be relative paths to the location of Android.mk, I'm adding a ../ to properly get to the util library's path.
The key for resources is the LOCAL_AAPT_FLAGS. This tells the resource packager to make sure it generates an R.java for the package in the utility library. Without this, all of the utility's resources will get put into the main applications R.java, and the utility classes will fail to compile because its R.java will be missing.