Search code examples
androidandroid-ndkandroid-sourceunsatisfiedlinkerrorandroid.mk

any easy way AOSP app development workflow?


i am trying development an app put in aosp source tree.it use aosp built system,and with some native code .it also is an system app.but development workflow is a bit annoying: i am modify my app code first.then go aosp dir,run mmm command,then use make command build system images and flash it to my android development board.then run app for test and check logcat,then back to modify code ....
is there any other workflow for development system app ?

i have tryed these method:

Android.mk with these line:

LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true

i can not use adb install install app apk file found in build out dir.

if i comment out that two lines,and set LOCAL_MODULE_TAGS := tests,then i can install apk use adb install command. but app is not system app,can not access some native api.

and my app have some native code.(not prebuilt library),aosp build apk but without my library.so my app can not running with error: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data

/app/com.mytest.app-IpmPY1ehtNYFMP3BCMb8HA==/base.apk"],nativeLibraryDirectories=[/data/app/com.mytest.app-IpmPY1ehtNYFMP3BCMb8HA==/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libmytest_jni.so"

then i am check my device filesystem,aosp not pack my library into system.img.

here is Android.mk for app:

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

LOCAL_SRC_FILES := \
            $(call all-subdir-java-files)

# LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := tests
LOCAL_PACKAGE_NAME := Mytest

LOCAL_SDK_VERSION := current

# with this two lines,i can not use adb install to update my app 
# without ,can not access some system api
# LOCAL_CERTIFICATE := platform
# LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false

LOCAL_JNI_LIBRARIES := libmytest_jni
LOCAL_REQUIRED_MODULES := libmytest_jni

include $(BUILD_PACKAGE)

#jni
include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH)) 

Android.mk for libmytest_jni library:

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

# with this line, library not pack into system.img
# without this line,is pack into system.img,but i must refulsh image file to test
# whatever with or without,library is not pack into apk file.
# LOCAL_MODULE_TAGS := tests

LOCAL_MODULE:= libmytest_jni

LOCAL_SRC_FILES:= \
    main_jni.cpp

LOCAL_SHARED_LIBRARIES := \
    libnativehelper \
    libcutils \
    libutils \
    liblog

LOCAL_C_INCLUDES += \
    $(JNI_H_INCLUDE)

LOCAL_CFLAGS +=

include $(BUILD_SHARED_LIBRARY)

Solution

    1. For a module to be added as part of system when you run full make, you'll have to add it in your device makefile, or device.mk a line like this: PRODUCT_PACKAGES += MyTest

    2. When building a specific module via mmm, you'll have to run make snodto re-generate system.img

    3. Instead of flashing system.img like in step 2, you can use adb sync. This will push any changed files to device. You might need to run adb reboot, or at least adb shell stop && adb shell start after.