Native Facebook Plugin - Invalid Key Hash


#1

Description:
While integrating an testing my latest update, I found everything ran locally to run perfect. As soon as I publish the update, then download it, I find the facebook login on my mobile device to say invalid hash. I tried to copy this exact key over to the facebook developer page, but still get the same response.

What gets me is that after making the apk file I transferred it over to my phone (signed) and tested. This worked perfect. I then upload it to Google and go download it that way and it fails.

Commands used:
ionic cordova build android --prod --release

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore fbs-release-key.jks ./platforms/android/build/outputs/apk/release/android-release-unsigned.apk fbs

zipalign -v 4 ./platforms/android/build/outputs/apk/release/android-release-unsigned.apk file_apk.apk

apksigner verify file_apk.apk


Command for getting key-hash
keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Password: android – No issues running the app debug locally

For production:
keytool -exportcert -alias -keystore .jks | openssl sha1 -binary | openssl base64

The key hash shown in the app is different that both of these. When testing on my wife’s phone I updated the app and her login worked perfectly. When I removed the app on her phone and re-installed it then failed. Her phone now doesn’t prompt giving an error on the key-hash, but just doesn’t work. Not sure why the signed and compiled .apk file installed directly on the phone works, but not when going through the play store.

Other:
Prior to integrating the native facebook plugin, I had nothing in the response when running apksigner verify. I am now getting the following:

WARNING: META-INF/android.arch.lifecycle_runtime.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_animated-vector-drawable.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_appcompat-v7.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_cardview-v7.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_customtabs.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-compat.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-core-ui.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-core-utils.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-fragment.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-media-compat.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-v4.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
WARNING: META-INF/com.android.support_support-vector-drawable.version not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.


#2

Well, I eventually got it… I attempted to copy/paste the error message into the developers.facebook.com page many times. The issue here was that what appeared to be a lowercase L was actually and uppercase i (I)

I thought I tried this (using capital i), but I ended up typing this in 5 different times and randomly worked. Would make it easier if you could copy/paste from this error, but either way all good now. Now time to remove all the failed string I inserted.

Still unsure why I am getting all of those META-INF warnings now. Online people say to remove the files, but I figured ionic would handle correcting this and would require doing this each time I compile. What I still don’t understand is why this worked on transferring the APK directly to the phone. I guess the signature changes once uploaded to Google?