patrickfav / uber-apk-signer

A cli tool that helps signing and zip aligning single or multiple Android application packages (APKs) with either debug or provided release certificates. It supports v1, v2 and v3 Android signing scheme has an embedded debug keystore and auto verifies after signing.
https://favr.dev/opensource/uber-apk-signer
Apache License 2.0
2.03k stars 205 forks source link

android:extractNativeLibs="false" #10

Closed ale5000-git closed 5 years ago

ale5000-git commented 6 years ago

Does it support apk files with android:extractNativeLibs="false"? In this case also the binary libraries must be stored uncompressed and zip-aligned.

patrickfav commented 6 years ago

Hi ale5000,

I'm not familiar with android:extractNativeLibs. Could you elaborate why it would be an issue with the signer? I basically use the first party tools/signing chain as provided by google (apk-signer & zipalign), so I'm not sure how to influence binary libs.

ale5000-git commented 6 years ago

Normally resources are stored uncompressed and zip-aligned so they can be used directly from the archive without extraction instead the binary libraries are extracted by Android on apk installation.

If android:extractNativeLibs="false" is set then binary libraries aren't extracted and they get the same treatment of resources.

I just want to know if it zip-align also binary libraries in addition to resources. PS: There is a flag (that now don't remember) to tell zipalign to align also libraries.

patrickfav commented 6 years ago

The only "odd" param I could find for https://developer.android.com/studio/command-line/zipalign is

-p : outfile.zip should use the same page alignment for all shared object files within infile.zip

As you can see I use the tool without any additional options https://github.com/patrickfav/uber-apk-signer/blob/ecc74783b156e2a1f729945a9902b6ad71fc6729/src/main/java/at/favre/tools/apksigner/SignTool.java#L244 If you want this checked I suggest you just try it out, I do not have an APK by hand with this specific build setup. I would very much appreciate a feedback/pull request if there is anything to fix.

ale5000-git commented 6 years ago

I'm not at home currently, but if you need an apk to test there is this: https://microg.org/fdroid/repo/com.google.android.gms-12221403.apk

patrickfav commented 6 years ago

Using your provided APK, no matter how I use zipalign, I cannot align it and verify:

Verifying alignment of .\apks\com.google.android.gms-12221403_align.apk (4)...
      49 AndroidManifest.xml (OK - compressed)
    8421 META-INF/CERT.RSA (OK - compressed)
   ...
   62415 assets/shaders/post_ssao.glsl (OK - compressed)
   63764 assets/shaders/texture_alpha.glsl (OK - compressed)
   64041 assets/shaders/texture_layer.glsl (OK - compressed)
   64453 assets/styles/microg.xml (OK - compressed)
   67792 assets/symbols/dot_white.svg (OK - compressed)
   68279 assets/symbols/transit/train_station.svg (OK - compressed)
   68755 assets/symbols/transit/train_station_small.svg (OK - compressed)
   69203 classes.dex (OK - compressed)
 1294936 lib/arm64-v8a/libvtm-jni.so (OK)
 1345916 lib/armeabi-v7a/libvtm-jni.so (OK)
 1392265 lib/armeabi/libvtm-jni.so (BAD - 1)
 1446780 lib/x86/libvtm-jni.so (OK)
 1493143 lib/x86_64/libvtm-jni.so (BAD - 3)
 1544365 org/oscim/tiling/source/mapnik/carto.xml (OK - compressed)
 1549068 org/oscim/tiling/source/oscimap2/TileData.proto (OK - compressed)
 1549627 res/anim/abc_fade_in.xml (OK - compressed)
 1549899 res/anim/abc_fade_out.xml (OK - compressed)
 1550188 res/anim/abc_grow_fade_in_from_bottom.xml (OK - compressed)
 1550622 res/anim/abc_popup_enter.xml (OK - compressed)
 ...
 1739610 res/drawable-xxhdpi-v4/ic_map_marker.png (BAD - 2)
 1741038 res/drawable-xxhdpi-v4/info.png (BAD - 2)
 1742022 res/drawable-xxhdpi-v4/location_marker.png (BAD - 2)
 1742822 res/drawable-xxhdpi-v4/self_check.png (BAD - 2)
 1743142 res/drawable-xxhdpi-v4/settings.png (BAD - 2)
 1744134 res/drawable-xxxhdpi-v4/abc_btn_check_to_on_mtrl_000.png (BAD - 2)
 1744502 res/drawable-xxxhdpi-v4/abc_btn_check_to_on_mtrl_015.png (BAD - 2)
 1745070 res/drawable-xxxhdpi-v4/abc_btn_radio_to_on_mtrl_000.png (BAD - 2)
 1745950 res/drawable-xxxhdpi-v4/abc_btn_radio_to_on_mtrl_015.png (BAD - 2)
 1746994 res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png (BAD - 2)
 1749590 res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png (BAD - 2)
 1752494 res/drawable-xxxhdpi-v4/abc_ic_menu_copy_mtrl_am_alpha.png (BAD - 2)
 1752914 res/drawable-xxxhdpi-v4/abc_ic_menu_cut_mtrl_alpha.png (BAD - 2)
 1753922 res/drawable-xxxhdpi-v4/abc_ic_menu_paste_mtrl_am_alpha.png (BAD - 2)
 1754482 res/drawable-xxxhdpi-v4/abc_ic_menu_selectall_mtrl_alpha.png (BAD - 2)
 1754882 res/drawable-xxxhdpi-v4/abc_ic_menu_share_mtrl_alpha.png (BAD - 2)
 1755870 res/drawable-xxxhdpi-v4/abc_ic_star_black_16dp.png (BAD - 2)
 1756558 res/drawable-xxxhdpi-v4/abc_ic_star_black_36dp.png (BAD - 2)
 1757914 res/drawable-xxxhdpi-v4/abc_ic_star_black_48dp.png (BAD - 2)
 1759686 res/drawable-xxxhdpi-v4/abc_ic_star_half_black_16dp.png (BAD - 2)
 1760154 res/drawable-xxxhdpi-v4/abc_ic_star_half_black_36dp.png (BAD - 2)
 1761006 res/drawable-xxxhdpi-v4/abc_ic_star_half_black_48dp.png (BAD - 2)
 1762102 res/drawable-xxxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_000.png (BAD - 2)
 1762622 res/drawable-xxxhdpi-v4/abc_scrubber_control_to_pressed_mtrl_005.png (BAD - 2)
 1763338 res/drawable-xxxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png (BAD - 2)
 ...
 1806048 res/layout-v17/abc_search_view.xml (OK - compressed)
 1807227 res/layout-v17/abc_select_dialog_material.xml (OK - compressed)
 1807808 res/layout-v17/abc_tooltip.xml (OK - compressed)
 1808361 res/layout-v17/app_bar.xml (OK - compressed)
 1809005 res/layout-v17/ask_gcm.xml (OK - compressed)
 1810076 res/layout-v17/ask_permission.xml (OK - compressed)
 1811183 res/layout-v17/condition_card.xml (OK - compressed)
 1812421 res/layout-v17/expand_button.xml (OK - compressed)
 1813252 res/layout-v17/games_info.xml (OK - compressed)
 1814159 res/layout-v17/list_no_item.xml (OK - compressed)
 1814760 res/layout-v17/login_assistant.xml (OK - compressed)
 1815652 res/layout-v17/notification_action.xml (OK - compressed)
 1816258 res/layout-v17/notification_action_tombstone.xml (OK - compressed)
 1816923 res/layout-v17/notification_template_big_media.xml (OK - compressed)
 1817649 res/layout-v17/notification_template_big_media_custom.xml (OK - compressed)
 1818720 res/layout-v17/notification_template_big_media_narrow.xml (OK - compressed)
 1819475 res/layout-v17/notification_template_big_media_narrow_custom.xml (OK - compressed)
 1820585 res/layout-v17/notification_template_custom_big.xml (OK - compressed)
 1821627 res/layout-v17/notification_template_lines_media.xml (OK - compressed)
 1822506 res/layout-v17/notification_template_media.xml (OK - compressed)
 1823095 res/layout-v17/notification_template_media_custom.xml (OK - compressed)
 ...
Verification FAILED

The only option I can see which may influence this is '-p', but it makes no difference. Any idea?

patrickfav commented 5 years ago

@ale5000-git Any idea? If your apk wont align, Im afraid theres not much I can do.