Android Studio does not create signed key in keystore - android-keystore

Using "Generate Signed Bundle or APK" I built my app following the documentation at https://developer.android.com/studio/publish/app-signing#generate-key but Android Studio does not generate a key. It builds the app but at the end of the build it shows an error:
No key with alias 'CBRP' found in keystore E:\Computer Projects\Android\samuelandroidkeystore.jks
Indeed, when I run command the key is not found:
keytool -list -keystore samuelandroidkeystore.jks
The passwords I entered are correct. Should I just create the key using keytool? I thought Android created the key into the keystore during the build.

Related

Flutter Project: Getting Kotlin Related Errors When Generating Signed APK in Android Studio

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.

No such signature was found on Play Console

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.

Create ionic 3 app with Target SDK version 30 getting error in google play console

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

Missing keystore in Flutter

I want to get the SHA-1 code, but I encountered an error.
C:\Users\erdem\AndroidStudioProjects\flutter_app\android>gradlew
signinReport
Missing Keystore
how can I solve this problem?
I was trying to get the SHA1 but I couldn't get because of the missing keystore error, I tried that and it worked for me I don't know if it really works.
If you have your own jks file and did lead it with key.properties but still gives the error Missing Keystore that worked for me :
Type keytool -alias "AndroidDebugKey" -genkeypair in the terminal of your android studio give it a password of android.
The rest of the fields or questions asked after that don't matter so just press Enter.
Go to your home directory (C:\Users) and look for a file named as .keystore.
Rename .keystore to debug.keystore.
Now copy and paste it to (C:\Users.android).
Re-run the signReport task to generate a new key for APP.
source: https://stackoverflow.com/a/63064024/7767761
Had the same issue. Cleanest fix I found is to generate a debug key:
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
gradlew signinReport will work after that.
Source
You can follow these steps:
Create a file named /android/key.properties that contains a reference to your keystore:
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, such as /Users/<user name>/key.jks>
I had the same problem.
This error comes when dubug.keystore file is missing in users/"Name"/.android/ directory and can be resolved by simply run your app on any mobile device it will create the debug.keystore file in the directory now the error should be gone on running signingreport.
cheers..!

Resigning my app with the same keystore failed

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