How to resign an APK in Dart

Viewed 138

I am working on an app that installs mods on Ren'Py Android apps (you usually have to do it manually, which is very tedious!), I've got everything ready to go, however, I am stuck in one place... Signing the APK file... To give you an idea of what I want to accomplish, this ZipSigner app does it, and I want to be able to do precisely what is being done here... Any idea how to accomplish this in Dart/Flutter?

I did notice that ZipSigner is open source, but it is written in Java, and my Java is about as bad as it gets :')

1 Answers

Basically you only need Jarsigner or Apksigner executables (which are available in the Android SDK tools) to resign an APK.

The full process that I like to follow is :

  1. Resigning the APK with Jarsigner
  2. Verifying the signature with Jarsigner
  3. Aligning the archive with Zipalign
  4. Analyzing is everything went well with Keytool

I wrote a bash script a while ago to ease this process :
https://github.com/FDuhen/android-resign--script

I didn't try it myself but, in theory, you should be able to embed this script and the associated binaries in a Flutter app, and execute it with a library like https://pub.dev/packages/process_run

Related