I am getting the following fatal error with code working perfectly on Android 4.1 and 4.3:
11-10 20:53:21.425 8940-8957/ganbi_collector.com.ganbi_collector E/NativeCrypto﹕ ssl=0x5ca3abe0 cert_verify_callback x509_store_ctx=0x5ee64ab0 arg=0x0
11-10 20:53:21.425 8940-8957/ganbi_collector.com.ganbi_collector E/NativeCrypto﹕ ssl=0x5ca3abe0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
11-10 20:53:21.502 8940-8940/ganbi_collector.com.ganbi_collector E/linker﹕ load_library(linker.cpp:759): library "libmaliinstr.so" not found
11-10 20:53:21.971 8940-8940/ganbi_collector.com.ganbi_collector E/SpannableStringBuilder﹕ SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
11-10 20:53:21.972 8940-8940/ganbi_collector.com.ganbi_collector E/SpannableStringBuilder﹕ SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
11-10 20:53:22.034 8940-8940/ganbi_collector.com.ganbi_collector E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at ganbi_collector.com.ganbi_collector.MainActivity.setUpMapIfNeeded(MainActivity.java:125)
at ganbi_collector.com.ganbi_collector.MainActivity.onLocationChanged(MainActivity.java:311)
at com.google.android.gms.internal.lx$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5434)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Here is the XML of the target activity
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/fragment_container">
<fragment
android:id="@+id/ganbi_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</FrameLayout>
And here is the methods caused the error:
private GoogleMap gMap;
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (gMap == null) {
gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.ganbi_map)).getMap();
// Check if we were successful in obtaining the map.
if (gMap != null) {
// The Map is verified. It is now safe to manipulate the map.
// Load map preferences
Log.d("Info", "Map ready for initialization");
gMap.setMyLocationEnabled(true);
LogMe(Boolean.toString(locationTrack));
}
}
}
public void onLocationChanged(Location loc) {
// Marks marks = new Marks();
String msg = "Location change received: " +
Double.toString(loc.getLatitude()) + "," +
Double.toString(loc.getLongitude());
LogMe(msg);
lastLoc = new LatLng(loc.getLatitude(),loc.getLongitude());
// Move the camera instantly to current location with a zoom of 15.
if (gMap == null){
setUpMapIfNeeded();
} else {
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lastLoc, 15));
// marks.getNearMarks(lastLoc);
getNearMarks(lastLoc);
}
}
I am debugging using Alcatel pop9 with andorid 4.2.2, the code was working perfeclty on HTC desire 500 with android 4.1 and the same code is workin with Alcatel Idol x2 with no problems.