Reputation: 13
I added a GoogleMap v2 in my Android application. In normal use, I don't have problem. However, if I reset my phone and install my app, the map crash.
report :
Caused by: java.lang.NullPointerException: CameraUpdateFactory is not initialized
When I update google services, this bug disappears.
anyone would have a track, or a way to force the user to update the Google services before use app ?
Thanks
Exception :
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.app/com.test.app.activity.AcHome}: java.lang.NullPointerException: CameraUpdateFactory is not initialized
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
at android.app.ActivityThread.access$600(ActivityThread.java:133)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4794)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: CameraUpdateFactory is not initialized
at com.google.android.gms.internal.s.b(Unknown Source)
at com.google.android.gms.maps.CameraUpdateFactory.aX(Unknown Source)
at com.google.android.gms.maps.CameraUpdateFactory.newLatLngZoom(Unknown Source)
at com.test.app.activity.AcHome.onCreate(AcHome.java:126)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
... 11 more
Upvotes: 0
Views: 171
Reputation: 3791
You can check before launching your maps activity if the user has an updated version of Google Play Services, or at least the one you need.
public static int isGooglePlayServicesAvailable (Context context)
Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.
Returns status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID, DATE_INVALID.
If you do this 'check' and receive 'update_required' then you can redirect the user to that update.
Is this what you are looking for?
Upvotes: 1