做dfu功能的時候,遇到的這樣一個問題灶似。添加了dfu的依賴之后,會要求編譯的sdk為28,我的AS版本默認生成的是27.然而target版本是25.
// The DFU Library is imported automatically from jcenter:
implementation 'no.nordicsemi.android:dfu:1.8.1'
implementation 'com.google.code.gson:gson:2.8.5'
修改sdk minsdk 和targetsdk版本
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.qiyi.newdfulibrary"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
添加合適的支持
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
生成apk后,準備放入到
vendor/qcom/proprietary/prebuilt_HY11/target/product/msm8998/system/priv-app
隨系統(tǒng)編譯,然后就如下錯誤
AILED: /bin/bash -c "(rm -f out/target/product/msm8998/obj/APPS/controllerota_intermediates/oat/arm64/package.odex ) && (mkdir -p out/target/product/msm8998/obj/APPS/controllerota_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx512m --runtime-arg -classpath --runtime-arg \"&\" --boot-image=out/target/product/msm8998/dex_bootjars/system/framework/boot.art --dex-file=vendor/qcom/proprietary/prebuilt_HY11/target/product/msm8998/system/priv-app/controllerota/controllerota.apk --dex-location=/system/priv-app/controllerota/controllerota.apk --oat-file=out/target/product/msm8998/obj/APPS/controllerota_intermediates/oat/arm64/package.odex --android-root=out/target/product/msm8998/system --instruction-set=arm64 --instruction-set-variant=generic --instruction-set-features=default --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info --abort-on-hard-verifier-error --no-inline-from=core-oj.jar --compile-pic )"
dex2oatd F 609 720 art/runtime/class_linker.cc:6620] Check failed: vtable_entry != other_entry && !name_comparator.HasSameNameAndSignature( other_entry->GetInterfaceMethodIfProxy(pointer_size)) vtable entries 1047 and 1052 are identical for java.lang.Class<android.support.v7.widget.MenuPopupWindow$MenuDropDownListView> in method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) and int android.support.v7.widget.MenuPopupWindow$MenuDropDownListView.lookForSelectablePosition(int, boolean)
dex2oatd F 609 720 art/runtime/runtime.cc:422]Runtime aborting...
Aborting thread:
原因是apk要預置進源碼的時候抱环,會對apk進行一個解析,好形成odex文件加速apk的運行途样,但是基于高版本的sdk開發(fā)的apk里面的一些資源是無法被低版本正確的解析的江醇,解決辦法就是濒憋,在mk文件里面禁止對該apk進行odex的處理何暇。LOCAL_DEX_PREOPT := false
include $(CLEAR_VARS)
LOCAL_MODULE := controllerota
LOCAL_MODULE_OWNER := qcom
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := false
LOCAL_MODULE_SUFFIX := .apk
LOCAL_SRC_FILES := system/priv-app/controllerota/controllerota.apk
LOCAL_PRIVILEGED_MODULE := true
include $(BUILD_PREBUILT)