abeljus
abeljus

Reputation: 402

Calabash-android resign with signature scheme v2

I'm trying to install and run a debug APK with Calabash-android, but it is failing because the scheme of the signature.

My original APK is signed with the debug keystore using scheme v2 (signed when building it via gradle):

$ apksigner verify -v myapp.apk
Verifies
Verified using v1 scheme (JAR signing): false
Verified using v2 scheme (APK Signature Scheme v2): true
Verified using v3 scheme (APK Signature Scheme v3): true

However, it cannot be used as it is with calabash-android (getting error No signature files found in META-INF. Cannot proceed.), so I need to resign it with calabash:

$ calabash-android resign myapp.apk

Signing process seems to work fine, but when I try to install the just signed APK I'm getting this error:

adb: failed to install /Users/acampos/myapp.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Scanning Failed.: No signature found in package of version 2 or newer for package com.myapp]

When trying to verify the signature of the new APK, this is the result:

$ apksigner verify -v myapp.apk
DOES NOT VERIFY
ERROR: Target SDK version 30 requires a minimum of signature scheme v2; the APK is not signed with this or a later signature scheme
...

It seems that the latest Android versions need scheme v2 for the signatures, but calabash resign action is still using v1.

I have already tried creating a new debug.keystore, changing to different versions (ruby, calabash-android, etc.),..., but no success.

Any idea about how to make calabash sign the APK using scheme v2?

Thank you!

Upvotes: 1

Views: 399

Answers (2)

BOBO-LU
BOBO-LU

Reputation: 3

I encountered a similar error while running an apk in Android 14.

No signature found in package of version 2 or newer for package

I uses zipalign tool to align with parameter 4 and signapk.jar to sign the apk. Both tools are built-in in AOSP.

zipalign -v -p 4 $UNCOMPRESSED_APK $ALIGNED_APK

java -jar signapk.jar platform.x509.pem platform.pk8 $ALIGNED_APK $FINAL_APK

I found the files at these locations under Android 14:

  • build/target/product/security/platform.x509.pem
  • build/target/product/security/platform.pk8
  • out/host/linux-x86/framework/signapk.jar

Upvotes: 0

Bartosz Olszanowski
Bartosz Olszanowski

Reputation: 818

I was able to get around this by using apksigner instead of calabash-android for signing the app.

Instead of resigning the app with calabash-android resign myapp.apk you can try to do the following:

  • sign the test server using calabash-android: bundle exec calabash-android build <path_to_apk>
  • sign the app using apksigner: apksigner sign --ks <path_to_debug_keystore> <path_to_apk>

Just make sure that you're signing the app with the same keystore that is being used to sign the test server.

Upvotes: 0

Related Questions