Reputation: 45
I have an android app build by android-studio that use gradle script, now I want to move app to AOSP build system. So how can I import the gradle script and convert to AOSP build (may be Android.bp or Android.mk). In gradle project have many dependency, android-studio can automatic download this dependency, can I do that in AOSP?
Upvotes: 2
Views: 3696
Reputation: 703
From my experience, you probably need to write Andorid.mk manually. By the way, AOSP build system not download dependencies automatically for you. If the dependencies are available in AOSP you no need to download them, just link to them. Otherwise, you need to download them to local directory then use Android.mk to add them to AOSP and linking.
This is an example of Android.mk. In which, the "libs" directory contains the libraries not available in AOSP.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := testapp
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_REQUIRED_MODULES := com.example.testapp
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_USE_AAPT2 := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_STATIC_ANDROID_LIBRARIES += \
androidx.lifecycle_lifecycle-extensions \
androidx.appcompat_appcompat \
androidx-constraintlayout_constraintlayout \
androidx.recyclerview_recyclerview \
androidx.cardview_cardview \
android-support-v4 \
LOCAL_STATIC_JAVA_LIBRARIES := \
cdi-api \
zxing-core \
http \
httpclient \
httpcore \
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
cdi-api:libs/cdi-api.jar \
zxing-core:libs/core-3.3.2.jar \
http:libs/http-2.2.1.jar \
httpclient:libs/httpclient-4.2.2.jar \
httpcore:libs/httpcore-4.2.3.jar \
include $(BUILD_MULTI_PREBUILT)
Upvotes: 5