Android源码编译Android Studio(带jar和jni)工程

1.把android studio工程删除到如下目录,

注意:如果在此目录下,有libs和jni目录
# cp -rf jni app/src/main

# cp -rf libs app/src/main

<1>.Android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(call first-makefiles-under,$(LOCAL_PATH))

2.进入app/src/main目录,libs目录为依赖的jar包,如下图所示

.Android源码编译Android Studio(带jar和jni)工程_第1张图片

<1>.Android.mk

 LOCAL_PATH:= $(call my-dir)
 
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_PACKAGE_NAME := test
LOCAL_CERTIFICATE := platform
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
 
LOCAL_SRC_FILES := $(call all-java-files-under, java)
LOCAL_STATIC_JAVA_LIBRARIES := testsdk test02
include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := testsdk:libs/testsdk-1.0.jar \                         
                                        test02:libs/test-2.0.jar
LOCAL_MODULE_TAGS := optional
include $(BUILD_MULTI_PREBUILT)
include $(call first-makefiles-under,$(LOCAL_PATH))

3.jni目录

<1>.Android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS:= optional

LOCAL_SHARED_LIBRARIES := libutils libcutils liblog
LOCAL_MODULE:=libtest
LOCAL_SRC_FILES:=test.c

include $(BUILD_SHARED_LIBRARY)

4.编译之后将libtest.so push到/system/lib下即可

你可能感兴趣的:(Android系统调试方法)