sisong / ApkDiffPatch

a C++ library and command-line tools for Zip(Jar,Apk) file Diff & Patch; create minimal delta/differential; support Jar sign(apk v1 sign) & apk v2,v3 sign .
MIT License
310 stars 49 forks source link

Problem with split apks (INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2) #72

Closed kasnder closed 3 years ago

kasnder commented 3 years ago

Hello,

I'm trying to use ZipDiff for the Twitter app.

When downloading for an arm64 device from the German Google Play Store, this comes in 5 .apk files:

Unfortunately, if I apply AndroidSDK#apksigner(ApkNormalized(AndroidSDK#apksigner(newZip))) to split_config.arm64_v8a.apk I get the following error when installing with adb install-multiple *.apk:

adb: failed to finalize session
Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]

Installing works without problems if I only apply AndroidSDK#apksigner(newZip) to split_config.arm64_v8a.apk and AndroidSDK#apksigner(ApkNormalized(AndroidSDK#apksigner(newZip))) tothe other .apk files.

kasnder commented 3 years ago

I assume that libraries within split_config.arm64_v8a.apk are wrongly compressed or aligned after running ApkNormalized.

kasnder commented 3 years ago

Additionally, I cannot run ZipDiff on split_config.arm64_v8a.apk without running ApkNormalized.

Running ZipDiff split_config.arm64_v8a.apk split_config.arm64_v8a-modified.apk split_config.arm64_v8a.ZipDiff results in:

...
check ZipPatch result Byte By Byte Equal ERROR!
  (did newZip=AndroidSDK#apksigner(ApkNormalized(AndroidSDK#apksigner(newZip))) before running ZipDiff?)
...
sisong commented 3 years ago

the cmdline ApkNormalized version is 1.3.6?
you can make it by yourself:

$cd <ApkdiffPatch>
$make

I have't tested with split apks,
Can you email these 5 .apk files to me(housisong@hotmail.com)?

kasnder commented 3 years ago

Oh, it's 1.3.5. I was using the tagged release from the webpage. I'll check again!

sisong commented 3 years ago

Possible attempt:

  1. packed apk files to one .apks (or .aab) file , and run apksigner?
  2. like bundletool , signed split apks
sisong commented 3 years ago

I Success!
I test Twritter split apks( base.apk split_config.arm64_v8a.apk split_config.de.apk split_config.en.apk split_config.xxhdpi.apk )
edit AndroidManifest.xml file in base.apk,changeandroid:extractNativeLibs="false" to android:extractNativeLibs="true"
then all apks do ApkNormalized & AndroidSDK#apksigner
run: adb install-multiple base.apk split_config.arm64_v8a.apk split_config.de.apk split_config.en.apk split_config.xxhdpi.apk
result "Success", and the TWritter app can be run on Android.

kasnder commented 3 years ago

Thanks for clarifying! I really don't like the latest changes to the APK format by Google..

sisong commented 3 years ago

same don't like

sisong commented 11 months ago

now, this lib new version supported page-align uncompressed .so files.