致命错误在Android 4.2.2谷歌地图V2 [英] Fatal error with google Map v2 on Android 4.2.2

查看:377
本文介绍了致命错误在Android 4.2.2谷歌地图V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用code在Android 4.1和4.3工作完美以下致命错误:

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)

下面是目标活动的XML

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);
    }

}

我使用阿尔卡特pop9用的Andorid 4.2.2调试中,code是搭载Android 4.1在同一code与阿尔卡特偶像X2,没有任何问题日夜不停上HTC渴望500工作perfeclty。

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.

推荐答案

@ zgc7009给我的钥匙在他神奇的词,该解决方案:这是一场比赛的情况下,描述通货膨胀之前获得地图的审判。我搬到从这场比赛获得地图,距离只有在进行此调用发生安全试用版本。

@zgc7009 Gave me the key to the solution in his magical word: it was a race case describing the trial of getting map before inflation. I moved the trial of getting map away from this race and only making this call happens safe later.

我有为什么它与其他设备的工作不同的解释:其实这是在Android开发的主要挑战之一,不同的硬件搭配不同的响应时间。看来,阿尔卡特pop9具有更好的GPS连接时间。我是初始化地图上GPS连接这是其他手机测试确定,其中GPS给出足够的时间让充气工作得到的。

I have different explanation on why it worked with other devices: actually this is one of the major challenges in Android development where different hardware with different response times. It seems that the Alcatel pop9 has much better GPS connection time. I was initializing the map get on GPS connection which was ok on other testing mobile phones where the GPS gives enough time for inflater to work.

这篇关于致命错误在Android 4.2.2谷歌地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆