How to add App signature scheme v2 to old apk - android

I have an apk using eclipse ADT and old keystore.
now app update on google play store requires using App Signature Scheme v2 and target API 30.
is there a way I can do to create a keystore signature scheme v2 file, without having to migrate my app from Eclipse ADT to Android Studio.
Thanks.

I am using this as a quick fix hack
after the zipalign step is done :
zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
I have followed this extra step:
apksigner sign --ks app.keystore --v1-signing-enabled true --v2-signing-enabled true HelloWorld.apk
Please note : use the same password you used for the keystore file.
So now you can upload your .apk file or .aab file to play store

With the help of this answer I managed to sign my Eclipse Android project with signature scheme v2. I am running Eclipse under Ubuntu.
Right click on the project and select Android Tools -> Export Unsigned Application Package...
Specify the destination of the unsigned apk file.
In the console execute this: zipalign -f 4 unsigned.apk signed.apk
and this: apksigner sign -ks path_to_keystore_file --v1-signing-enabled true --v2-signing-enabled true signed.apk
Enter the password for the keystore.
Enter the password for the signer.
zipalign and apksigner I installed before with sudo apt install zipalign apksigner.
I am using Eclipse for Android Developers with version "Oxygen Release Milestone 2 (4.7.0 M2) Build id: 20160922-0846".

After build for release -> jarsigner -> zipalign,
I just need these scripts. To sign the apk with APK Signature Scheme v2:
apksigner sign --ks yourkeystore.keystore yourapk.apk
To verify the signing
apksigner verify -v yourapk.apk

Related

Signed apk unable to install in Android 12

I got 'App not installed as package appears to be invalid' message when trying to install my signed release app manually on Android 12. However, it can be installed in my other phones which are Android 9 and Android 6.
I use jarsigner to sign my apk :
$ jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore my-release-key.keystore <app-release-unsigned.apk's path> alias_name
And use zipalign to optimize :
$ zipalign -v 4 <path-to-same-apk-file> HelloWorld.apk
I've change my phone setting so that able to install unknown apk and tested with app-debug.apk and it works just fine. For more information, my app is written by using quasar framework and built by using cordova.
On Android 12, you have to use V2 signing scheme to sign your APK. Unfortunately, jarsigner is only v1 signing scheme.
In short, use apksigner to sign your APK in place or jarsigner, or if you use Android Studio, don't forget to check the "V2 signing" check box or define the signingConfig enabling v2 signing.

Unexpected parameter(s) after input APK (--out): Can't sign the apk for prod build

I am trying to do a production build of an apk but when I try to sign it with the following command:
apksigner.bat sign --ks app-release-key.jks --out app-release-unsigned.apk app-release-unsigned-aligned.apk
I get the below error:
Unexpected parameter(s) after input APK (--out)
I am following this to sign the app manually from the command line.
I'm using the apksigner .bat file located at ../Android/Sdk/build-tools/32.0.0 and as you can see I'm using Android build tools 32.0.0. I've tried different things
Using jarsigner to sign the app, and although it successfully signed the app, my app would not load when I installed it onto the device. Also, according to this we should use apksigner if we're using build-tools 24.0.3 and older.
Tried to use this as well
apksigner.bat sign --ks test.jks --ks-key-alias test --ks-pass pass:testtest --key-pass pass:testtest Test_Aligned.apk from here but it gave me the error Unexpected parameter(s) after input APK (--ks-key-alias)
Tried using the jar apksigner located at ../Android/Sdk/build-tools/32.0.0/bin but I'm receiving the same error.
Any suggestions would help. Thanks.

Cannot update debug APK on device

I face a problem when trying to install debug type .apk file over another one on my device. I have an app with versionCode=n already installed. When I try to install the same app with versionCode=n+1 i get an error.
Here is the message after i call the command adb install xxx.apk
failed to install xxx.apk: Failure
[INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package xxx signatures do not
match the previously installed version; ignoring!]
All my .apk files are signed with Android debug keystore. It is confirmed by command jarsigner -verify -verbose -certs xxx.apk that gives me next message:
Signed by "C=US, O=Android, CN=Android Debug"
Digest algorithm: SHA-256
Signature algorithm: SHA256withRSA, 2048-bit key
jar verified.
These .apk files are built via TeamCity CI that just calls assembleDebug command.
It is very strange because I can update release APK files built by CI easily. This problem occurs only in case of debug builds.
Do you have any idea about this?
Thanks in advance
Each debug build of your android application will be signed with the debug keystore.
This is a problem because in continous integration environments, like travis-ci or docker, the debug keystore is regenerated on each creation of the environment.
This means if someone has a debug version of your application, they won't be able to upgrade to a more recent version, because the keystores will be different.
Credits to: https://newfivefour.com/android-debug-build-constant-signed-keystore.html
Also to compare if two apks are signed with the same key:
check: How do I find out which keystore was used to sign an app?

Google Play Console signing error/invalid signature after rebuilding react-native

Our team decided to upgrade our react-native version from 0.59.x to 0.61.5. We have so many difficulty upgrading it so we decide to start a new repo from fresh (npx react-native init appName) and copy over our code.
After we make sure the app are running both on Android and ios simulator. We use the same scripts to build the .aab file and upload to Google Play Console. But Google Play Console won't let us. This is the error message shown:
Upload failed
You uploaded an APK with an invalid signature (learn more about
signing). Error from apksigner:
There is no other error message after "apksigner:" so I am pretty sure it is a different problem than other similar questions on stack overflow.
I am also sure that we are using the same keystore file
Below is how we build our .aab file
curl "http://localhost:8081/index.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
cd $REPO_PATH/android
./gradlew bundleRelease
cd ..
# sign the aab
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/my-release-key.keystore $REPO_PATH/android/app/build/outputs/bundle/release/app.aab traytAndroidKey
# zipalign the aab and output it to another file
$HOME/Library/Android/sdk/build-tools/28.0.3/zipalign -f -v 4 $REPO_PATH/android/app/build/outputs/bundle/release/app.aab $REPO_PATH/android/app/build/outputs/bundle/release/app-release-signed-aligned-$VERSION_CODE.aab
Please help :(
It seems that you are uploading an AAB and not an APK.
AABs don't need to be zip-aligned.
Try only signing with jarsigner.
Also, try verifying the signature with jarsigner too.

How to sign APK in release mode in VS 2017 native app?

How to sign your APK or Android App Bundle in release mode in Visual Studio Native-Activity Application (Android) project?
When I rebuild solution and deploy solution in release ARM target, navigate to Release folder and drag and drop apk file to play.google.com (Play Store), there is following error message.
Upload failed
You uploaded a debuggable APK or Android App Bundle. For security reasons you need to disable debugging before it can be published in Google Play. Learn more about debuggable APKs or Android App Bundles.
You uploaded an APK or Android App Bundle that was signed in debug mode. You need to sign your APK or Android App Bundle in release mode. Learn more about signing.
I have manged to generate and download deployment_cert.der on play store, but not sure how it can be added to apk in Visual Studio Native-Activity Application (Android) project.
Figered it out now.
Built APK file can be signed by using command line (without need of installing Android Studio). This can be done as follows:
1.) Bellow will allow to build unsigned APK in release mode:
.packing project Properties --> Ant --> Ant Build Target --> Release (Release Mode)
2.) Add JDK and Android SDK to PATH. In my case (installed by VS installer) those paths are:
C:\Program Files\Java\jdk1.8.0_172\bin
C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3
3.) Create keystore with key:
keytool -genkey -v -keystore my_app.keystore -alias alias_name -keyalg PSA -keysize 2048 -validity 10000
4.) Sign APK:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my_app.keystore My.App.Packaging-release-unsigned.apk alias_name
5.) ZIP align:
zipalign -f -v 4 My.App.Packaging-release-unsigned.apk My.App.apk
6.) Drag and drop to Play Store

Categories

Resources