I have some issues with the signature of my apk created in Unity. I've followed these steps:
Built the apk with the Unity Build Settings
Created a keystore with Unity Keystore Manager
Signed the apk with the following command
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore mykeystore.keystore myapk.apk alias
Aligned the signed apk with the following command:
zipalign -f -v 4 myapk.apk zipalignedapk.apk
At this point, I try loading the zipaligned apk on the Google Play Console release page, but I'm getting this error:
"You loaded an APK with a non valid signature. Error in apksigner: ERROR (Jar signer CERT.RSA): JAR signature META-INF/CERT.SF indicates the APK is signed using APK Signature Scheme v2 but no such signature was found. Signature stripped?"
Can anyone tell me what's wrong? Is there any different procedure to sign an APK for Play Console using Unity?
Thanks all.
Related
I am able to build an unsigned APK using flutter build apk --split-per-abi --no-tree-shake-icons. However, when I attempt to generate a signed APK, I get several Kotlin related errors. To be clear, I can build the project without signing just fine. However, when I attempt to generate a signing key (via Android Studio) the process fails with the errors shown below. I believe the signing process uses 'tools.jar' which is available in JDK 8. I have added JDK 8 (liberica-1.8) to the project structure. I've seen some postings indicating openjdk#8 is not compatible with M1 Macs. The JDK 8 included with Android Studio, however, indicates that it supports aarch64 so I assume this isn't a problem. Nevertheless, I cannot determine the source of these errors.
MainActivity.kt:
I'm using the APK key generation process in Android Studio to sign my APK (Build > Generate Signed Bundle / APK):
I am not attempting to run ProGuard at this time:
I am running on Apple silicon. I've tried flutter clean and invalidating caches.
After further investigation and testing, I believe the bundle and APK signing process that's built into Android Studio (Bumblebee 2021.1.1) will not work on a M1 Mac. I tested this process using a variety of JDKs. Each time, I get the same errors I shared earlier (JDK 8 must be used to avoid a missing tools.jar problem). I strongly suspect (but have not yet tested) that this same signing process works fine on Intel Macs.
As a workaround for M1 Macs, I am posting a comprehensive solution found here that is derived from posts by RichardC and Kit.
(A) To generate the keystore:
keytool -genkey -v -keystore ~/Desktop/upload-keystore.keystore -alias upload -keyalg RSA -keysize 2048 -validity 10000
(B) To sign an APK:
jarsigner -verbose -keystore ~/Desktop/upload-keystore.keystore ~/Desktop/app-armeabi-v7a-release.apk upload
(C) If the above command fails, try this one (SDK must be at least 1.7):
jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore ~/Desktop/upload-keystore.keystore ~/Desktop/app-armeabi-v7a-release.apk upload
(D) To zip align an APK:
~/Library/Android/sdk/build-tools/32.0.0/zipalign -f -v 4 ~/Desktop/app-armeabi-v7a-release.apk ~/Desktop/app-armeabi-v7a-release-za.apk
NOTE: make sure to check/replace 32.0.0 as needed.
(E) If the APK file is already signed, remove the original sign with following code:
Zip -d ~/Desktop/app-armeabi-v7a-release.apk META-INF/*
I was able to sign the APKs I built with Flutter flutter build apk --split-per-abi --no-tree-shake-icons using these CLI commands with no issues on my M1 Mac. Hopefully a future release of Android Studio corrects this issue.
I am create my app in ionic v3 with Target SDK version 30
when i am upload my apk on google play console i am getting 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"
When i am making apk with Target SDK version 29 and upload on google play console its upload without any error
i don't no whay google give me an error
create sign in apk proccess are same in Target SDK version 30 or Target SDK version 29 same keystore and all command are same for create sign apk
My command are
ionic cordova build --release android
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myappname.keystore app-release-unsigned.apk myapp
zipalign -v 4 app-release-unsigned.apk myappname.apk
Please Check what is wrong on about command and let me know it's argent my client are waiting a Target SDK version 30
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
Solution
i am use this solution for ionic app only using cmd
After zipalign command success apply this command for conver sign apk with signature scheme v2
apksigner sign --v2-signing-enabled false --ks keystore name.keystore signapkname.apk
apksigner sign --ks keystore name.keystore signapkname.apk
apksigner sign --ks keystore name.keystore --ks-key-alias aliasname signapkname.apk
keytool -printcert -jarfile signapkname.apk
apksigner verify -v --print-certs signapkname.apk
apksigner verify -v signapkname.apk
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
After uploading updated APK to play store I see this error message:
enter image description here
You are trying to upload unsigned apk to play store so you are getting this error.
Please create a singed apk with your keystore or jks then upload to play tore.
Publishing Apk
Step 1. Create Keystore (keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000)
Step 2. build apk (ionic cordova build android --prod --release)
Step 3. jarsign the unsigned apk using the keystore (jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOU_KEYSTORE.keystore android-release-unsigned.apk YOUR_APK_NAME)
Step 4. Zipalign the unsigned apk ( /home/USER_NAME/Android/Sdk/build-tools/25.0.2/zipalign -v 4 android-release-unsigned.apk YOUR_APK_NAME.apk )
try to add a file under platforms/android called release-signing.properties. Than fill out the data. With this the apk will be signed during every build.
storeFile=../../keystore/yourkeystore.keystore
storeType=jks
keyAlias=yourAlias
keyPassword=yourPassword
storePassword=yourStorePassword
If it's still not working than you signed the apk in the play store with a different key.
If you want to update your app then you need to sign your application with keytool you used for the initial release using that only you can update your application. Please sign the unsigned apk using the previous keytool and try to upload that apk in playstore.
Thanks for your support. problem is solved now. I deleted both .jks file and release-signing.properties from dir and created unsigned apk again.
I suppose the problem is signing two times APK.
I am trying to add crosswalk to my ionic. My apps are launched and working fine. However after I added Crosswalk, I can't generate signed apks anymore. I tried to remove crosswalk and it works again. How did you guys manage to get it working?
Here's what I did:
cordova plugin add cordova-plugin-crosswalk-webview
cordova platform add android
ionic build android
it builds fine except:
BUILD SUCCESSFUL
Total time: 1 mins 34.909 secs
Built the following apk(s):
<--- this part is empty, usually it'll show the path of the apk generated
In Android Studio I get this error for the gradle sync.
NDK integration is deprecated in the current plugin.
When I try to generate signed apk, I get this error:
Missing Gradle Project Information. Please check if the IDE successfully synchronized its state with the Gradle Project Model.
I tried cordova platform add android#4.1, instead of using latest one. And I was able to build it with sdk 22.
However when I try to publish, I'm getting this problem.
It is forbidden to downgrade devices which previously used M permissions (target SDK 23 and above) to APKs which use old style permissions (target SDK 22 and below). This occurs in the change from version 103098 (target SDK 23) to version 104004 (target SDK 22).
The steps I followed to get signed apk is as-
open terminal and go to android file
$ cd projectDir/platforms/android
and run this command to generate digital signature
$ keytool -genkey -v -keystore exampleapp.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000
# This will create a file in you "projectDir/platforms/android" directory with a name of exampleapp.keystore which will have digital signature.
# Now Create a file with name of release-signing.properties here in
projectDir/platforms/android directory.
# Provide details to this file about your signature.
*# signed apk details
storeFile=exampleapp.keystore
keyAlias=mindfull
storePassword=password
keyPassword=password*
Go to terminal and exit to main project directory by typing
$ cd ../..
Run this command to build signed apk.
$ cordova build android --release
this will run many task and show something like this-
Now you can upload this apk on play store and share with your friend.
Have a nice day !!!
For more you can see here
https://randvblog.wordpress.com/2016/07/04/generate-signed-apk-for-android-using-gradle-for-cordova-6-0-0-in-ionic/
Salam all,
I've created an app for android 2.2 using Eclipse and I have signed using a keystore that I have created, then I have upload it to the Market.
I have done some changes on the app, I have changed the app version from 1.0 tp 1.1, then I have tried to sign the new generated .apk file but I've got the following error:
jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 525 but got 527 bytes).
This error occurs when you try to sing a signed .apk file, I have generated an unsigned .apk from Eclipse and my app signed successfuly.
Now the Market refuses my new signed app, I guess that the first version was signed by Eclpise and my keystore, now I cannot have a new version signed by both. is this true analysis?
What am I doing wrong?
To get an unsigned apk in Eclipse, right click on application name in the Package Explorer window and choose Android Tools, then choose "Export Unsigned Application Package...". Save the package to a new location.
Once you have an unsigned apk. Run the jarsigner command you were using on the unsigned apk file.
$ jarsigner -verbose -keystore my-release-key.keystore my_application.apk alias_name
$ jarsigner -verify my_signed.apk
$ jarsigner -verify -verbose -certs my_application.apk
Note: If you see "CN=Android Debug", this means the .apk was signed with the debug key generated by the Android SDK. If you intend to release your application, you must sign it with your private key instead of the debug key.
$ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
$ zipalign -c -v <alignment> existing.apk
Source:
http://forum.xda-developers.com/showthread.php?t=492822
http://developer.android.com/guide/developing/tools/zipalign.html
This fixed my issue