Android Studio. Building signed APK. Get Key Failed - android

I've been building release versions of my app for months, and now all of a sudden I get this error.
Failed to read key ******** from store ***** Get Key Failed. Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
This is beyond frustrating.
What I've done so far
Read every post on this error and tried every solution
Verified my passwords are correct
Checked and unchecked "save passwords"
Verified my keystore location is correct

If you get error like block not properly padded, bad key or PKCS12 when signing the App Bundle or APK, try using the same password for the key and the keystore file, it works for me.

Recently, Android Studio started to show a message: "Warning: Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified -keypass value. in Android Studio" - so, first of all, store and key passwords should be the same, like other people said.
Besides, after getting this error even using the same password, I realized that we can't use characters like # or $ on the passwords.

Just Remove space from folder name ,where your jks file stored

Related

Android Studio APK Error: Invalid Keystore Format

I am trying to build an app in Flutter but have come across a big issue. In order to enable app check, sign up using Facebook, etc. I need to get my SHA-1 fingerprint. I have tried to get it by running gradlew signingReport in the terminal of Android Studio; however, I get the following error:
"failed to read key androiddebugkey from store invalid keystore format"
I've read previous posts relating to this but nothing has been able to help me. If anyone could be of assistance, that would be great :).
By deleting the keystore file itself. Android Studio will generate a new one, which don't have the same error.

Locating the release keystore for an old android application on a dev machine

I need to locate the release signing key for an android app from 4+ years ago. I have the codebase, and the MBP it was last worked on, but the person who worked on it was very disorganized.
I have multiple directories called /proj, /proj2, /desktop_proj, /old/proj...each has 2-3 apks in it. Source control is a similar mess.
I don't know what IDE they used to work on this project. I have IntelliJ, Eclipse, and Android Studio on this old machine. I can search all of them but I don't know where to look.
I did a find and none of the keystores (.jks or .keystore) really match up.
Basically, I was thinking to go the other way -- get the current release apk from google play and check out the keystore on it.
keytool -list -printcert -jarfile super-old-app__release.apk
Then, I can ... do something ... to find the actual name of the key used to create the signing build. Though now that I think of it, I don't know the passwords.
Anyways, maybe I can find that, once I get the actual keys. Does anyone possibly have any suggestions?
If you know alias used in app, you can reverse search it for all files ( search for .JKS or .keystore or without extension ).
Write a batch program searching in complete disk with taking file name as input parameter running
keytool -list -keystore XXX.XXX -alias **YOURAPPAliasname**
Write output of above batch program to a file. All files except one should return you java.lang.Exception: Alias does not exist or incorrect format.
You can modify above batch program to additionally find signature of key to match with signed key. See solutions provided in this link - How do I find out which keystore was used to sign an app?

Having trouble with Maps API auth after migrating Android project to another computer

So I had an Android app up and running on my old computer. That computer experienced tragic technical difficulties, and so I had to nuke it. Luckily I had all my project files backed up. After getting back to a successful build, the Android application in question now posts the following error when starting a maps activity
05-26 10:46:17.259 29771-30465/com.mypack.android E/b: Authentication failed on the server.
05-26 10:46:17.259 29771-30465/com.mypack.android E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
Uh oh! So I remember how much of a pain this was to set up, and I look at the text file I wrote to guide me should I ever have issues with it again.
I have both /release/values/google_maps_api.xml and a /debug/values/google_maps_api.xml both with fingerprints and package names listed, as well as a string for the key itself. For simplicity's sake, I'll use the following as the debug credentials
fingerprint: AB:CD:12:34
package name: mypack
I've gone into my google developer console and under the Android Maps API, I've enabled it and added those credentials to an Android API key named mypack key. Under said credentials I've placed the debug fingerprint: AB:CD:12:34 as well as the release key fingerprint and the sha1 keystore fingerprint given by keytool -list -v -keystore mystore.keystore all of which are tied to com.mypack.Android (which is the package name in my AndroidManifest.xml.) Is this too many? I've tried singling out each one - only having one at a time but stil...
no luck!
So what I figure happened was that when migrating my project, the key values under google_maps_api.xml must have been invalidate - in some way shape or form the SHA-1 certificate fingerprints are bad. I'm not sure how to validate the fingerprints, maybe there's a way to regenerate the google_maps_api.xml files for this project?

How to solve keystore load: invalid keystore formtat?

I'm getting a releasekey to my app Three months ago. Now I format my computer and when I was sign my app with my releasekey i got the error: java.lang.RunTimeException: keystore load: invalid keystore format.
How I should solve this error?
The command was: jarsigner -verbose -keystore "D:\releasekey.keystore" "D:\myApp.apk" releasekey
I'm using the older keystore (the fisrt one) but I get the error mentioned.
I tried and get this:
java.io.IOException: java.io.IOException: invalid keystore format
at sun.security.provider.javaKeyStore.engineLoad(JavaKeyStore.java:650)
at sun.security.provider.javaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
at java.security.KeyStrore.load(KeyStore.java:1214)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:789)
at sun.security.tools.KeyTool.run(KeyTool.java:340)
at sun.security.tools.KeyTool.main(KeyTool.java:333)
The keystore holds the private encryption key used to sign the app - rerunning the command would generate a totally different key (the password just protects the file holding it - it does not have a directly relationship with the encryption key itself) - You can NOT recover/rebuild it if you lost the keystore file.
If you lost it then your users would have to uninstall the existing app completely before they can install your new version - and they will loose any data saved in the app when they uninstall it (no way around this, it's a security feature in android)
Worse then that - android play store isn't going to let you upload your new version because they aren't encoded using the same key as the old version - you'll need to release the new version under a Different package name - That means your existing users can't even upgrade automatically (they have to find the new version) - and you have no way of even telling them that they need to upgrade (you can't upload a new version of the old app...)
You gotta find that keystore file in your backups or try to recover the data from the disk - hopefully you did a 'quick' format - in which case a good data recovery service Might be able to get it back if your OS hasn't over-written it yet.
Goodluck!

Android invalid key and Facebook Connect

When I try to implement Facebook Connect in my Android application, I get the following error.
11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed:
invalid_key:Android key mismatch. Your key
"8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys
specified in your application settings. Check your application
settings at http://www.facebook.com/developers
I reset the key in the Facebook App and still it shows the same error. How can I fix it?
Your key is: "8Ioc4p/jMXoU9Lezug4nzmZfFUg"
Now copy this key and open this URL, and paste this key in the native Android app, marked with a green border.
I dont know if your problem is resolved right now but I was having the same problem as you and now I find the complete solution.
You have two enviroments for the development: debug and a signed application, when you use this commands to get your key
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 you are getting the key for the debug.keystore,
But when you sign the app you get a new key because your app is using a new keystore.You can get your "sign app key" using this program. http://www.easyfacebookandroidsdk.com/download/keyhash.zip but you have to sign with the same keystore that you are using in your app.
Your key is
8Ioc4p/jMXoU9Lezug4nzmZfFUg
This key is encrypted by your device so you have we have to let this key be known to Facebook user (in your application which you create in Facebook).
Now you have to copy this key in the native app and then save it. After some minutes, you can get all access..
The error for me was caused by the mismatch between my debugging key when I was testing my app and the release key when I was signing a release version.
11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed:
invalid_key:Android key mismatch. Your key
"8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys
specified in your application settings. Check your application
settings at http://www.facebook.com/developers
If you copy and paste 8Ioc4p/jMXoU9Lezug4nzmZfFUg to the Android Key Hash field in the Facebook application settings it should work. If you get this error again (showing a different key value) when you test your signed release version, copy that additional key into the Hash Field after the original entry, so you have two values in there.
I was surprised that more than one entry was allowed in the Key Hash Field, but it appears it is ok and it's solved the problem for me for both testing and release versions.
The debug native Android application key is generated automatically using debug.keystore file located at ~/.android/debug.keystore. When you are developing your application on multiple machines, you should have the same debug.keystore file...
Once this is done, you can paste the debug native Android application key to the Facebook settings page of your application.
You actually do not past this key directly, but a Base64 value of this key.
Refer to https://developers.facebook.com/docs/mobile/android/build/#sig which explains you how to generate this.
Please check your application page in Facebook and confirm that both keys are same. I think you won't register your app on Facebook
You can use Facebook application in your application so you use this.
In that source code for Facebook integration is there.
If the key is invalid, then you have to create the new Facebook application on the Facebook developers site. It provides you with a new key. Use that key in your Facebook demo.
I have this problem, I solved it by deleting "C:\Users\user_name.android\debug.keystore" and generating a new one with eclipse. Then I change the old hash key from Facebook and it works!

Categories

Resources