Ad
Google Places API Multiple Developers
We are a team working together on an android application.
unfortunately, only the one wrote the code using the google places API can run the activity, while the others can't.
We experienced the same problem with the google maps API, but that was due to the fact that we all used the same API key.
after changing the API key (each individual the his own key) the problem stopped.
This is the code causing the crash (again, the person wrote the activity manages to run it)
public void refreshPlacesData() {
Uri uri = PlaceContract.PlaceEntry.CONTENT_URI;
Cursor data = getContentResolver().query(
uri,
null,
null,
null,
null);
if (data == null || data.getCount() == 0) return;
List<String> guids = new ArrayList<String>();
while (data.moveToNext()) {
guids.add(data.getString(data.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_PLACE_ID)));
}
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(mClient,
guids.toArray(new String[guids.size()])); <---this is where it crash
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
mAdapter.swapPlaces(places);
mGeofencing.updateGeofencesList(places);
if (mIsEnabled) mGeofencing.registerAllGeofences();
}
});
}
and this is the error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rubz.dvir.rubz, PID: 25203
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {com.rubz.dvir.rubz/com.rubz.dvir.rubz.JobRequestActivity}: java.lang.NullPointerException: GoogleApiClient must not be null
at android.app.ActivityThread.deliverResults(ActivityThread.java:3382)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3425)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: GoogleApiClient must not be null
at com.google.android.gms.common.internal.zzbq.zza(Unknown Source)
at com.google.android.gms.common.api.internal.zzm.<init>(Unknown Source)
at com.google.android.gms.location.places.zzm$zzb.<init>(Unknown Source)
at com.google.android.gms.location.places.zzm$zzc.<init>(Unknown Source)
at com.google.android.gms.location.places.internal.zzl.<init>(Unknown Source)
at com.google.android.gms.location.places.internal.zzh.getPlaceById(Unknown Source)
at com.rubz.dvir.rubz.JobRequestActivity.refreshPlacesData(JobRequestActivity.java:445)
at com.rubz.dvir.rubz.JobRequestActivity.onActivityResult(JobRequestActivity.java:515)
at android.app.Activity.dispatchActivityResult(Activity.java:5467)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3378)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3425)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Application terminated.
Ad
Answer
You can add multiple SHA-1's to your places api , goto cloud console
and then select Google Places Api, restrict your Api , and then add SHA's
Hope this helps
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad