背景
Android Studio版本
androidstudio
debug版本可以安裝運行正常腹尖,release版本安裝不上广鳍,使用adb指令報錯:
Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION]
網(wǎng)上搜到的結(jié)果
-
沒有使用正確的簽名姿勢 reference
android 2.3 之前使用v1簽名,對應(yīng)android7 之前平绩。所以如果在較舊的設(shè)備上安裝release版本需要使用v1版簽名丁溅,至少簽名時候需要勾選v1,v2也可以一起勾選上
未能完全卸載debug版本
在簽名配置中添加 zipAlignEnabled false 關(guān)閉zip壓縮優(yōu)化 reference
但是有送,這些都不解決我的問題 ??
重點來了
使用原生Google系統(tǒng), adb install xxx.apk 之后發(fā)現(xiàn)更多可用的debug信息
Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed reading res/raw/xxx.xxx in android.util.jar.StrictJarFile@5fdc588: META-INF/MANIFEST.MF has invalid digest for res/raw/xxx.xxx in res/raw/xxx.xxx]
原因:打包中的文件的安全驗證與META-INF/MANIFEST.MF 中的不符
產(chǎn)生原因:
發(fā)現(xiàn)相關(guān)的文件是在module library中的 res/asset僧家,打包過程由于android studio的原因雀摘,未能把module library 模塊庫按照release進行打包融合到release版本的apk中
解決辦法
現(xiàn)將module library使用 assembleRelease
打包成 xxx-release.aar 包,然后使用放入到app的libs路徑下八拱,重新添加依賴阵赠。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.aar'])
...
}