ChatGPT解决这个技术问题 Extra ChatGPT

Difference between signature versions - V1 (Jar Signature) and V2 (Full APK Signature) while generating a signed APK in Android Studio?

Please select at least one of the signature versions to use in Android Studio 2.3

Now while generating a signed APK in Android Studio, it's showing two options (CheckBox) namely 1. V1 (Jar Signature) and 2. V2 (Full APK Signature) as Signature Versions in the last step of signed APK generating process.

https://i.stack.imgur.com/1CPP5.png

So, what is the difference between V1 (Jar Signature) and V2 (Full APK Signature) in the new Android Studio update?

And which should I use (or both) for signing apk for play store release?

Also, I'm getting error Install Parse Failed No Certificates while installing APK when I use the second option.

for me once i chose v2, then built is fine. but once i want to check those boxes, they're not shown anymore... where are they?? @f.khantsis
does the newer version not include these options?....

B
Booger

It is a new signing mechanism introduced in Android 7.0, with additional features designed to make the APK signature more secure.

It is not mandatory. You should check BOTH of those checkboxes if possible, but if the new V2 signing mechanism gives you problems, you can omit it.

So you can just leave V2 unchecked if you encounter problems, but should have it checked if possible.

UPDATED: This is now mandatory when targeting Android 11.


You should re-word your question though, it looks like you haven't even read the documentation that was linked...it is useful to know you can leave that checkmark unchecked. Perhaps if you add the "error message and problem you encountered), then this question will become more valuable for the future
I have uploaded app by signed application using V1 and V2. After that I download the application from google play and run same version from Android Studio it show me dialog of "Installation failed since the device has an application with the same package but a different signature. . . .." Can you suggest me what I am doing wrong need to update the build.gradle?
@UsmanAfzal, it is expected behavior since you signed the app on the playstore with release, and now you want to debug or run it through Android Studio with debug. Notice that release and debug are different signature
Thanks @EugenMartynov I updated the answer to indicate this...it is a popular answer, so I appreciate you pointing that out (so I could update this).
C
Chintan Rathod

Should I use(or both) for signing apk for play store release? An answer is YES.

As per https://source.android.com/security/apksigning/v2.html#verification :

In Android 7.0, APKs can be verified according to the APK Signature Scheme v2 (v2 scheme) or JAR signing (v1 scheme). Older platforms ignore v2 signatures and only verify v1 signatures.

I tried to generate build with checking V2(Full Apk Signature) option. Then when I tried to install a release build in below 7.0 device and I am unable to install build in the device.

After that I tried to build by checking both version checkbox and generate release build. Then able to install build.


but those checkbox options are now not showing, where are they??
t
toto_tata

It is written here that "By default, Android Studio 2.2 and the Android Plugin for Gradle 2.2 sign your app using both APK Signature Scheme v2 and the traditional signing scheme, which uses JAR signing."

As it seems that these new checkboxes appeared with Android 2.3, I understand that my previous versions of Android Studio (at least the 2.2) did sign with both signatures. So, to continue as I did before, I think that it is better to check both checkboxes.

EDIT March 31st, 2017 : submitted several apps with both signatures => no problem :)


S
Shirish Herwade

According to this link: signature help

APK Signature Scheme v2 offers:

Faster app install times More protection against unauthorized alterations to APK files.

Android 7.0 introduces APK Signature Scheme v2, a new app-signing scheme that offers faster app install times and more protection against unauthorized alterations to APK files. By default, Android Studio 2.2 and the Android Plugin for Gradle 2.2 sign your app using both APK Signature Scheme v2 and the traditional signing scheme, which uses JAR signing.

It is recommended to use APK Signature Scheme v2 but is not mandatory.

Although we recommend applying APK Signature Scheme v2 to your app, this new scheme is not mandatory. If your app doesn't build properly when using APK Signature Scheme v2, you can disable the new scheme.


Hi @Shirish , can we make v2 builds from eclipse ?
It;s mandatory now, because you cannot choose signature version - that option has been removed and all apks use v2. Thus, you cannot generate apk instsallable on old phones.
G
Gastón Bengolea

I think this represents a good answer.

APK Signature Scheme v2 verification

Locate the APK Signing Block and verify that: Two size fields of APK Signing Block contain the same value. ZIP Central Directory is immediately followed by ZIP End of Central Directory record. ZIP End of Central Directory is not followed by more data. Locate the first APK Signature Scheme v2 Block inside the APK Signing Block. If the v2 Block if present, proceed to step 3. Otherwise, fall back to verifying the APK using v1 scheme. For each signer in the APK Signature Scheme v2 Block: Choose the strongest supported signature algorithm ID from signatures. The strength ordering is up to each implementation/platform version. Verify the corresponding signature from signatures against signed data using public key. (It is now safe to parse signed data.) Verify that the ordered list of signature algorithm IDs in digests and signatures is identical. (This is to prevent signature stripping/addition.) Compute the digest of APK contents using the same digest algorithm as the digest algorithm used by the signature algorithm. Verify that the computed digest is identical to the corresponding digest from digests. Verify that SubjectPublicKeyInfo of the first certificate of certificates is identical to public key. Verification succeeds if at least one signer was found and step 3 succeeded for each found signer.

Note: APK must not be verified using the v1 scheme if a failure occurs in step 3 or 4.

JAR-signed APK verification (v1 scheme)

The JAR-signed APK is a standard signed JAR, which must contain exactly the entries listed in META-INF/MANIFEST.MF and where all entries must be signed by the same set of signers. Its integrity is verified as follows:

Each signer is represented by a META-INF/.SF and META-INF/.(RSA|DSA|EC) JAR entry. .(RSA|DSA|EC) is a PKCS #7 CMS ContentInfo with SignedData structure whose signature is verified over the .SF file. .SF file contains a whole-file digest of the META-INF/MANIFEST.MF and digests of each section of META-INF/MANIFEST.MF. The whole-file digest of the MANIFEST.MF is verified. If that fails, the digest of each MANIFEST.MF section is verified instead. META-INF/MANIFEST.MF contains, for each integrity-protected JAR entry, a correspondingly named section containing the digest of the entry’s uncompressed contents. All these digests are verified. APK verification fails if the APK contains JAR entries which are not listed in the MANIFEST.MF and are not part of JAR signature. The protection chain is thus .(RSA|DSA|EC) → .SF → MANIFEST.MF → contents of each integrity-protected JAR entry.


where it says "Note: APK must not be verified using the v1 scheme if a failure occurs in step 3 or 4", step 3 or 4 in Scheme 2 or scheme 1 ? also if a failure occurs in step 3 or 4 in v2 and then its saying it can't be verified using v1 scheme then it will not be verified in v1 or v2 how will it be verified ?