Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't upload signed apk that targetSdkVersion is 30

I generated a signed apk with a target sdk version of 30. (Android 11). I know it wasn't officially released but my application is ready for the new changes. I am trying to upload it to the google play console but facing the error:

You uploaded an APK with an invalid signature (learn more about signing). Error from apksigner: ERROR: MIN_SIG_SCHEME_FOR_TARGET_SDK_NOT_MET: Target SDK version 30 requires a minimum of signature scheme v2; the APK is not signed with this or a later signature scheme.

What I tried to do:

  1. I double checked that I selected v2 (Full APK Singature) when I generated the apk.
  2. I tried to manually sign the apk using apksigner.

Nothing worked. I'm wondering if it's not working since the version wasn't released yet. However, I understand that it suppose to work from the documents.

like image 800
Ofek Pintok Avatar asked Aug 04 '20 12:08

Ofek Pintok


4 Answers

Short answer for those building Cordova projects on the command line: You'll need to switch from jarsigner to apksigner and set up the command accordingly. NOTE: You'll need to run zipalign before apksigner, which is different from how we used to use it with jarsigner. Here's an example:

cordova build android --release

zipalign -f 4 platforms/android/app/build/outputs/apk/release/myapp-release-unsigned.apk myapp.apk

apksigner sign --ks my-ks.keystore --ks-pass file:my-passfile.txt --v1-signing-enabled true --v2-signing-enabled true myapp.apk

... upload apk to store or whatever ... 
like image 179
sherb Avatar answered Nov 08 '22 16:11

sherb


Select both V1 and V2(Full Apk Signature) while generating the apk. This solved my issue which was similar to yours.

like image 26
bhaskar Avatar answered Nov 08 '22 18:11

bhaskar


Generate an App Bundle instead of an APK.

In my app I targeted api 30 and published the bundle without problems.

like image 7
Viatcheslav Ehrmann Avatar answered Nov 08 '22 18:11

Viatcheslav Ehrmann


I had a tough time solving that issue. The following helped me resolve it completely.

  1. Add the following 2 lines in config.xml (root directory of the Cordova project)
<preference name="android-minSdkVersion" value="30"/>

<preference name="android-targetSdkVersion" value="30"/>
  1. Import your project in AndroidStudio
  2. Under Build Click on Generate Signed Bundle / APK

enter image description here

  1. Select Android App Bundle

enter image description here

  1. Update Keystore file/password and all requested details (Please select the option of the export encrypted key, as you will require to upload this on the playstore)

enter image description here

  1. Select Release

enter image description here

  1. Before uploading the app bundle you need to upload the certificate (the one you download in step 4)

enter image description here

  1. (optional step) You will also see an auto-generated App signing key certificate you can download that if you want

  2. Upload the App Bundle & you can now release the App to PlayStore.

like image 4
Utpal - Ur Best Pal Avatar answered Nov 08 '22 18:11

Utpal - Ur Best Pal