2014-09-23 76 views
2

我想讓我的應用程序使用Android源代碼構建。如何在Android.mk文件中包含appcompat_v7以及在源代碼中放置appcompat_v7文件夾的位置。我使用下面的代碼,如何在Android.mk文件中包含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) 

我收到錯誤

化妝:沒有規則,使目標的出/目標/普通/ OBJ/JAVA_LIBRARIES/\ appcompat_v7_intermediates/javalib.jar', 'out/target/common/obj/APPS/MyPackage_intermediates/classes-full-debug.jar'需要。停止。

任何人請幫忙。提前致謝。

回答

3

我是能夠建立一個包括程序兼容性使用下面的Android.mk

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

0

此代碼對我的作品,我希望它可以幫助!將appcompat_v7項目的庫中的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) 
+0

實際上,appcompat_v7項目是爲了使項目與舊版本的SDK兼容而創建的。因此,爲了避免自動生成此項目,您可以在創建自己的Android項目時將SDK版本的最低要求設置爲高於4.0。 – gxlzlihao 2015-06-18 02:44:51

0

我在命令行中構建了我的包以及Android源代碼,並且很難包含v7 appcompat。對我來說,將android-support-v7-appcompat.jar複製到libs並更改上面公佈的其他Android.mk並不能解決我的問題。我終於明白,我需要先構建v7 appcompat。

  1. 轉到PATH/TO/frameworks/support/v7/appcompat並首先構建它。
  2. 不需要將appcompat.jar複製到庫。讓你的Android.mk像上面的兩個帖子,它應該工作。