我希望我的应用程序可以使用Android源代码构建。如何在Android.mk文件中包含appcompat_v7以及将appcompat_v7文件夹放在源代码中的位置。我使用以下代码,
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := \appcompat_v7
# Include all java files.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := MyPackage
include $(BUILD_PACKAGE)
我收到错误
制作:没有规则要制作目标' out / target / common / obj / JAVA_LIBRARIES / \ appcompat_v7_intermediates / javalib.jar',需要' out / target / common / obj / APPS / MyPackage_intermediates /班,全debug.jar&#39 ;.停止。
任何人都请帮忙。提前谢谢。
答案 0 :(得分:5)
我能够使用以下Android.mk构建包含appcompat的包
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := MySuperAwesomeApp
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/gridlayout/res
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout
include $(BUILD_PACKAGE)
来源:https://android.googlesource.com/platform/packages/apps/UnifiedEmail/+/android-5.0.1_r1/Android.mk
答案 1 :(得分:0)
此代码适用于我,我希望它可以提供帮助!将appcompat_v7项目的libs中的jar文件复制到项目的libs目录中。
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
android-support-v7-appcompat
<more jar could be added here>
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := <The name of your App project>
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += <The absolute path to your appcompat_v7 project>/res
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v4:android.support.v7.appcompat <replace the _ with . for your all jar files>
include $(BUILD_PACKAGE)
答案 2 :(得分:0)
我在命令行中使用Android源代码构建了我的包,并且很难包含v7 appcompat。对我来说,将android-support-v7-appcompat.jar复制到libs并更改上面发布的其他Android.mk并没有解决我的问题。我终于弄明白我需要先构建v7 appcompat。