From 2183f0553c660dab120cac6e01bc5eb58f567767 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Jul 2022 11:38:12 +0200 Subject: [PATCH] android/meson.build: use apksigner instead of jarsigner This is required for targetSdkVersion=30. apksigner requires running zipalign first. --- android/apk/meson.build | 53 ++++++++++++++++++++--------------------- android/meson.build | 2 +- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/android/apk/meson.build b/android/apk/meson.build index fc9c81737..1695ef502 100644 --- a/android/apk/meson.build +++ b/android/apk/meson.build @@ -12,18 +12,30 @@ unsigned_apk = custom_target( ], ) +aligned_apk = custom_target( + 'mpd-aligned.apk', + output: 'mpd-aligned.apk', + input: unsigned_apk, + command: [ + android_zipalign, + '-f', '4', + '@INPUT@', '@OUTPUT@', + ], +) + if get_option('android_debug_keystore') != '' debug_apk = custom_target( 'mpd-debug.apk', output: 'mpd-debug.apk', - input: unsigned_apk, + input: aligned_apk, command: [ - jarsigner, - '-keystore', get_option('android_debug_keystore'), - '-storepass', 'android', - '-signedjar', '@OUTPUT@', - '@INPUT@', - 'androiddebugkey', + apksigner, 'sign', + '--in', '@INPUT@', + '--out', '@OUTPUT@', + '--debuggable-apk-permitted', + '-ks', get_option('android_debug_keystore'), + '--ks-key-alias', 'androiddebugkey', + '--ks-pass', 'pass:android', ], build_by_default: true ) @@ -31,29 +43,16 @@ endif if get_option('android_keystore') != '' and get_option('android_keyalias') != '' and get_option('android_keypass') != '' unaligned_apk = custom_target( - 'mpd-unaligned.apk', - output: 'mpd-unaligned.apk', - input: unsigned_apk, - command: [ - jarsigner, - '-digestalg', 'SHA1', '-sigalg', 'MD5withRSA', - '-keystore', get_option('android_keystore'), - '-storepass', get_option('android_keypass'), - '-signedjar', '@OUTPUT@', - '@INPUT@', - get_option('android_keyalias'), - ], - ) - - apk = custom_target( 'mpd.apk', output: 'mpd.apk', - input: unaligned_apk, + input: aligned_apk, command: [ - android_zipalign, - '-f', '4', - '@INPUT@', '@OUTPUT@', + apksigner, 'sign', + '--in', '@INPUT@', + '--out', '@OUTPUT@', + '-ks', get_option('android_keystore'), + '--ks-key-alias', get_option('android_keyalias'), + '--ks-pass', 'pass:' + get_option('android_keypass'), ], - build_by_default: true ) endif diff --git a/android/meson.build b/android/meson.build index a8caa0243..75134e942 100644 --- a/android/meson.build +++ b/android/meson.build @@ -17,7 +17,7 @@ android_dx = join_paths(android_build_tools_dir, 'dx') android_zipalign = join_paths(android_build_tools_dir, 'zipalign') javac = find_program('javac') -jarsigner = find_program('jarsigner') +apksigner = find_program('apksigner') rsvg_convert = find_program('rsvg-convert') convert = find_program('convert') zip = find_program('zip')