My Android application makes use of two APIs: Google Maps API v2 (identified by the package com.google.android.gms.maps
) and Facebook API (com.facebook
) (this last one has been solved thanks to @RINK)
Both the services were installed in my project by following their official tutorials and they worked fine until yesterday, where something in my code changed and I obviously can't figure out what. I'm pretty sure that the cause is related to the debug/release key that signs my application before being installed on my testing phone.
In particular, I'm working with the debug key that it's stored in my personal folder (I'm on Windows + Netbeans) by default and it's regenerated every time I delete it: C:\Users\Alessandro\.android\debug.keystore
.
Both Maps and Facebook need to know the SHA-1 fingerprint of such key, I've retrived it using keytool
. Having it, I put it on the dedicated API service pages:
- Google's Console API in the form
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.UpMap
- and Facebook's App Dev page, Key Hashes field.
As I said, everything worked fine but suddenly the Maps in my application became blank and Facebook Login raises an error:
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue com.facebook.http.protocol.ApiException: remote_app_id does not match stored id
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:74)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:103)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.http.protocol.ApiResponse.h(ApiResponse.java:208)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:266)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:27)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:141)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:284)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:185)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:245)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:51)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:191)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at com.facebook.common.executors.HandlerExecutorServiceImpl$ListenableScheduledFuture.run(HandlerExecutorServiceImpl.java:268)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at android.os.Handler.handleCallback(Handler.java:587)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at android.os.Handler.dispatchMessage(Handler.java:92)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at android.os.Looper.loop(Looper.java:123)
11:24:51.064 1708 #1708 WARN fb4a(:<default>):BlueServiceQueue at android.os.HandlerThread.run(HandlerThread.java:60)
I readed the question Android Facebook SDK 3.0 gives "remote_app_id does not match stored id" while logging in and I should be in the same problem, but the fact is that the "Key Hash" which I generated using keytool is good.
I've tried to:
- delete the stored debug key and regenerate it, updating it's SHA and saving it on Google and Facebook
- check if the API Keys provided by Google and Facebook and written in my AndroidManifest.xml are correct
- check if the package name of my app is correct
- clean and rebuild the entire project, including Google and Facebook source libraries
This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.UpMap"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
<permission android:name="com.UpMap.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.UpMap.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<application android:label="@string/app_name" android:allowBackup="true">
<uses-library android:name="com.google.android.maps" />
<activity
android:name="MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="LevelActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"
android:windowSoftInputMode="adjustPan|adjustResize"
android:screenOrientation="portrait"
uiOptions="splitActionBarWhenNarrow">
<meta-data
android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
<activity
android:name="FacebookActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"
android:windowSoftInputMode="adjustPan|adjustResize"
android:screenOrientation="portrait">
</activity>
<activity android:name="com.facebook.LoginActivity"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<HIDDEN_GOOGLE_KEY>"
/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/fb_app_id"/>
</application>
</manifest>
This is the code of the Activity that shows the Google Map:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/LevelLayout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/where_is_it"
android:textSize="28sp"
android:layout_margin="5dp"
android:layout_marginBottom="0dp"
/>
<LinearLayout
android:id="@+id/SolutionLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="5dp"
android:background="#000000"
android:gravity="center"
>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="300dp"
>
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/TheMap"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:mapType="satellite"
map:uiRotateGestures="false"
map:uiScrollGestures="false"
map:uiTiltGestures="false"
map:uiZoomControls="false"
map:uiZoomGestures="false"
/>
<LinearLayout
android:id="@+id/MapOverlay"
android:clickable = "true"
android:onClick="mapOverlayClick"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="80dp"
android:paddingBottom="80dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:background="#00000000"
>
<TextView
android:id="@+id/HintView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:background="#AA000000"
android:padding="10dp"
android:gravity="center"
android:visibility="invisible"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
And I use this line to retrieve the GoogleMap object in the code:
GoogleMap theMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.TheMap)).getMap();
I can't figure out what the problem is, maybe I think I'm signing the application with the debug key specified above... but actually the real used key is in another path?