Ronak Joshi Ronak Joshi - 3 years ago 226
Android Question

Android Google Place Picker working in Signed APK but not working in Live app

I have an application in which i have used Google Place Picker. There is very strange issue i am facing. When i am creating signed APK with my app's keystore, Place Picker is working very well. That same APK I have uploaded over Google PlayStore. When I come to open that Place Picker it automatically closed down. I already read a lots of comments online and also here in SO. But I can not determine why its working well in signed APK and the same APK which is over Google PlayStore is not working.

When i checked logs of LIVE application of Google PlayStore it giving error like this :

Volley : [198] BasicNetwork.performRequest: Unexpected response code 403
for https: //www.googleapis.com/placesandroid/v1/search?key=MY_KEY/ ? V / ConnectivityManager : isActiveNetworkMetered() returns: true
/ ? E / AsyncOperation : serviceID = 65, operation = SearchPlaces
OperationException[Status {
statusCode = PLACES_API_INVALID_APP, resolution = null
}]


I already have checked into my Google Developer Console that my key is same or not. I also check my SHA which I have created from my KeyStore file. And all are good (Otherwise it will also not works in Signed APK if anything wrongs there).

Here is how I calling Place Picker from my Activity

int PLACE_PICKER_REQUEST = 999;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);


Here is my AndroidManifest.xml file where i have give my API key in meta data which is into application tag.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example" >
// ALL PERMISSIONS ARE HERE
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/MY_KEY" />
</application>
</manifest>


There is file which i deleted "release/values/google_maps_api.xml" which is automatic generated. As i already mentioned my API key into string.xml, So I deleted this whole values package from release package.

Can anyone tell me what is wrong with this?

Answer Source

After several days of investing time for finding solution of this problem. Finally I got the solution. It is because of Google Play App Signing .

With Google Play App Signing: You sign your app with your upload key. Then, Google verifies and removes the upload key signature. Finally, Google re-signs the app with the original app signing key you provided and delivers your app to the user.

So, when I Created API key for "Google Places API for Android" I have restricted that key using my package name and my SHA-1 of Signed APK's KeyStore.

Now that is under "Upload Certificate" and it is not used, as I have to pass my App Singing Certificate's SHA-1 to Google Developer Console. And after doing that my Google PlayStore's live app's Google PlacePicker working well. enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download