安裝包含jni的工程apk到system/app下
1、簽名了app,push apk 到/system/app下(push前需要mount下system目錄),出現錯誤說是找不到對應的lib***.so檔案:
“Couldn't load WatchDog from loader dalvik.system.PathClassLoader[dexPath=/system/app/FactoryTest.apk,libraryPath=/data/app-lib/com.starnet.factorytest-1]: findLibrary returned null”
解決:把所需要的庫(在工程libs/armeabi目錄下的.so檔案)push到/system/lib/下即可。
而對於安裝到/data/app(正常安裝)目錄下的app不需要手動push所需要的so檔案,也不會出現錯誤。
2、我的工程有三個.c檔案,設定了生成對應的.so檔案
Android.mk檔案:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TARGET_PLATFORM := android-3
LOCAL_MODULE := WatchDog
LOCAL_SRC_FILES := WatchDog.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
TARGET_PLATFORM := android-3
LOCAL_MODULE := Led
LOCAL_SRC_FILES := Led
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
TARGET_PLATFORM := android-3
LOCAL_MODULE := SerialPort
LOCAL_SRC_FILES := SerialPort.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
若是隻生成一個.so檔案,只要:
Android.mk檔案:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TARGET_PLATFORM := android-3
LOCAL_MODULE := FactoryTest
LOCAL_SRC_FILES := WatchDog
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
即可。
3、對於libs下的armeabi、armeabi-v7a、x68資料夾(沒有可以手動新增)、預設下是隻編譯armeabi的。若是要全部編譯,只要在jni資料夾下新增application.mk檔案:
Application.mk檔案:
APP_ABI := armeabi armeabi-v7a x86
即可。。。