'How to sign apk file with v2 or v3 programmatically?

I have made an app that signs apk files with v1 signature programmatically , but I need a way to sign apk files with v2 or up (v3 .. v4) like apk signer (in play store)

My problem is I can't find a way to create my own v2 apk signer

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source