Compile AndroidStudio project in Android source code

Write a shell script cp.sh in the AS and directory, copy all the required files before compiling, and then compile it in the android source code


#!/bin/bash
LIBS="Application/src/main/libs"
SRC="Application/src/main/java/*"
RES="Application/src/main/res"
JNI="Application/src/main/jni"
ANDROIDMANIFEST="Application/src/main/AndroidManifest.xml"
ANDROIDMK="Android.mk"


DES="/path/to/AndroidSourceCode/MyApp"
rm -fr $ DES
mkdir -p $DES/src

cp -r $LIBS $DES
cp -r $SRC $DES/src
cp -r $ RES $ DES
cp -r $JNI $DES
cp $ANDROIDMANIFEST $DES
cp $ANDROIDMK $DES

Create a new Android.mk in the root directory of the AS project, configure various dependencies, and use the conceal demo of fb in the example.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
#LOCAL_CERTIFICATE := platform


LOCAL_STATIC_JAVA_LIBRARIES := \
        android-support-v4 \
        android-support-annotations \
        conceal_android \
        conceal

LOCAL_PACKAGE_NAME := MyApp
#LOCAL_PROGUARD_ENABLED := disabled
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_JNI_SHARED_LIBRARIES := libconceal

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
    conceal_android:libs/conceal_android.jar \
    conceal:libs/libconceal.jar
include $(BUILD_MULTI_PREBUILT)

include $(CLEAR_VARS)
LOCAL_MODULE := libconceal
LOCAL_SRC_FILES := libs/armeabi-v7a/libconceal.so
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
include $(BUILD_PREBUILT)

include $(call all-makefiles-under,$(LOCAL_PATH))

The second method is to specify the paths of files such as src, res, and AndroidManifest.xml in Android.mk, so there is no need to copy them with scripts.

LOCAL_SRC_FILES := $(call all-java-files-under, Application/src/main/java)
LOCAL_MANIFEST_FILE := Application/src/main/AndroidManifest.xml
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/Application/src/main/res
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
#LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_SRC_FILES := $(call all-java-files-under, Application/src/main/java)
LOCAL_PACKAGE_NAME := MyApp
LOCAL_CERTIFICATE := platform
LOCAL_MANIFEST_FILE := Application/src/main/AndroidManifest.xml
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/Application/src/main/res

#LOCAL_PROGUARD_ENABLED := disabled
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_PACKAGE)
https://blog.csdn.net/abc_1234d/article/details/72510700


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325921281&siteId=291194637