异常信息:
04-28 14:54:39.781: D/dalvikvm(30873): Trying to load lib /data/data/com.fyfeng.baidumaptest/lib/libvi_voslib.so 0x42028510 04-28 14:54:39.789: D/dalvikvm(30873): Added shared lib /data/data/com.fyfeng.baidumaptest/lib/libvi_voslib.so 0x42028510 04-28 14:54:39.789: D/dalvikvm(30873): No JNI_OnLoad found in /data/data/com.fyfeng.baidumaptest/lib/libvi_voslib.so 0x42028510, skipping init 04-28 14:54:39.789: D/dalvikvm(30873): Trying to load lib /data/data/com.fyfeng.baidumaptest/lib/libapp_BaiduMapApplib_v2_1_1.so 0x42028510 04-28 14:54:39.789: D/dalvikvm(30873): Added shared lib /data/data/com.fyfeng.baidumaptest/lib/libapp_BaiduMapApplib_v2_1_1.so 0x42028510 04-28 14:54:39.961: W/System.err(30873): java.lang.StringIndexOutOfBoundsException: length=15; regionStart=0; regionLength=-1 04-28 14:54:39.961: W/System.err(30873): at java.lang.String.startEndAndLength(String.java:593) 04-28 14:54:39.961: W/System.err(30873): at java.lang.String.substring(String.java:1474) 04-28 14:54:39.969: W/System.err(30873): at com.baidu.platform.comapi.d.c.j(Unknown Source) 04-28 14:54:39.969: W/System.err(30873): at com.baidu.platform.comapi.d.c.g(Unknown Source) 04-28 14:54:39.969: W/System.err(30873): at com.baidu.platform.comapi.d.c.c(Unknown Source) 04-28 14:54:39.969: W/System.err(30873): at com.baidu.platform.comapi.a.a(Unknown Source) 04-28 14:54:39.969: W/System.err(30873): at com.baidu.mapapi.BMapManager.init(Unknown Source) 04-28 14:54:39.969: W/System.err(30873): at com.fyfeng.baidumaptest.MainActivity.onCreate(MainActivity.java:26) 04-28 14:54:39.969: W/System.err(30873): at android.app.Activity.performCreate(Activity.java:5185) 04-28 14:54:39.969: W/System.err(30873): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 04-28 14:54:39.969: W/System.err(30873): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071) 04-28 14:54:39.969: W/System.err(30873): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132) 04-28 14:54:39.969: W/System.err(30873): at android.app.ActivityThread.access$700(ActivityThread.java:140) 04-28 14:54:39.969: W/System.err(30873): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) 04-28 14:54:39.969: W/System.err(30873): at android.os.Handler.dispatchMessage(Handler.java:99) 04-28 14:54:39.969: W/System.err(30873): at android.os.Looper.loop(Looper.java:137) 04-28 14:54:39.969: W/System.err(30873): at android.app.ActivityThread.main(ActivityThread.java:4918) 04-28 14:54:39.969: W/System.err(30873): at java.lang.reflect.Method.invokeNative(Native Method) 04-28 14:54:39.969: W/System.err(30873): at java.lang.reflect.Method.invoke(Method.java:511) 04-28 14:54:39.969: W/System.err(30873): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 04-28 14:54:39.969: W/System.err(30873): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 04-28 14:54:39.969: W/System.err(30873): at dalvik.system.NativeStart.main(Native Method) 04-28 14:54:40.000: D/dalvikvm(30873): Trying to load lib /data/data/com.fyfeng.baidumaptest/lib/libvi_voslib.so 0x42028510 04-28 14:54:40.000: D/dalvikvm(30873): Shared lib '/data/data/com.fyfeng.baidumaptest/lib/libvi_voslib.so' already loaded in same CL 0x42028510 04-28 14:54:40.000: W/System.err(30873): java.lang.StringIndexOutOfBoundsException: length=15; regionStart=0; regionLength=-1 04-28 14:54:40.008: W/System.err(30873): at java.lang.String.startEndAndLength(String.java:593) 04-28 14:54:40.008: W/System.err(30873): at java.lang.String.substring(String.java:1474) 04-28 14:54:40.008: W/System.err(30873): at com.baidu.platform.comapi.d.c.j(Unknown Source) 04-28 14:54:40.008: W/System.err(30873): at com.baidu.platform.comapi.d.c.c(Unknown Source) 04-28 14:54:40.008: W/System.err(30873): at com.baidu.platform.comapi.a.a(Unknown Source) 04-28 14:54:40.008: W/System.err(30873): at com.baidu.mapapi.BMapManager.init(Unknown Source) 04-28 14:54:40.008: W/System.err(30873): at com.fyfeng.baidumaptest.MainActivity.onCreate(MainActivity.java:26) 04-28 14:54:40.008: W/System.err(30873): at android.app.Activity.performCreate(Activity.java:5185) 04-28 14:54:40.008: W/System.err(30873): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 04-28 14:54:40.008: W/System.err(30873): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071) 04-28 14:54:40.008: W/System.err(30873): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132) 04-28 14:54:40.008: W/System.err(30873): at android.app.ActivityThread.access$700(ActivityThread.java:140) 04-28 14:54:40.008: W/System.err(30873): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) 04-28 14:54:40.008: W/System.err(30873): at android.os.Handler.dispatchMessage(Handler.java:99) 04-28 14:54:40.008: W/System.err(30873): at android.os.Looper.loop(Looper.java:137) 04-28 14:54:40.008: W/System.err(30873): at android.app.ActivityThread.main(ActivityThread.java:4918) 04-28 14:54:40.008: W/System.err(30873): at java.lang.reflect.Method.invokeNative(Native Method) 04-28 14:54:40.008: W/System.err(30873): at java.lang.reflect.Method.invoke(Method.java:511) 04-28 14:54:40.008: W/System.err(30873): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 04-28 14:54:40.008: W/System.err(30873): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 04-28 14:54:40.008: W/System.err(30873): at dalvik.system.NativeStart.main(Native Method) 04-28 14:54:40.055: W/System.err(30873): java.lang.StringIndexOutOfBoundsException: length=15; regionStart=0; regionLength=-1 04-28 14:54:40.055: W/System.err(30873): at java.lang.String.startEndAndLength(String.java:593) 04-28 14:54:40.055: W/System.err(30873): at java.lang.String.substring(String.java:1474) 04-28 14:54:40.055: W/System.err(30873): at com.baidu.platform.comapi.d.c.j(Unknown Source) 04-28 14:54:40.055: W/System.err(30873): at com.baidu.platform.comapi.d.c.e(Unknown Source) 04-28 14:54:40.055: W/System.err(30873): at com.baidu.platform.comapi.a.a(Unknown Source) 04-28 14:54:40.055: W/System.err(30873): at com.baidu.mapapi.BMapManager.init(Unknown Source) 04-28 14:54:40.055: W/System.err(30873): at com.fyfeng.baidumaptest.MainActivity.onCreate(MainActivity.java:26) 04-28 14:54:40.062: W/System.err(30873): at android.app.Activity.performCreate(Activity.java:5185) 04-28 14:54:40.062: W/System.err(30873): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 04-28 14:54:40.062: W/System.err(30873): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071) 04-28 14:54:40.062: W/System.err(30873): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132) 04-28 14:54:40.062: W/System.err(30873): at android.app.ActivityThread.access$700(ActivityThread.java:140) 04-28 14:54:40.062: W/System.err(30873): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) 04-28 14:54:40.062: W/System.err(30873): at android.os.Handler.dispatchMessage(Handler.java:99) 04-28 14:54:40.062: W/System.err(30873): at android.os.Looper.loop(Looper.java:137) 04-28 14:54:40.062: W/System.err(30873): at android.app.ActivityThread.main(ActivityThread.java:4918) 04-28 14:54:40.062: W/System.err(30873): at java.lang.reflect.Method.invokeNative(Native Method) 04-28 14:54:40.062: W/System.err(30873): at java.lang.reflect.Method.invoke(Method.java:511) 04-28 14:54:40.062: W/System.err(30873): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) 04-28 14:54:40.062: W/System.err(30873): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 04-28 14:54:40.062: W/System.err(30873): at dalvik.system.NativeStart.main(Native Method) 04-28 14:54:40.109: D/Test(30873): /storage/sdcard0/BaiduMapSDK 04-28 14:54:40.820: D/dalvikvm(30873): GC_CONCURRENT freed 206K, 7% free 9626K/10311K, paused 13ms+2ms, total 32ms 04-28 14:54:40.820: D/dalvikvm(30873): WAIT_FOR_CONCURRENT_GC blocked 14ms 04-28 14:54:40.883: D/libEGL(30873): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so 04-28 14:54:40.891: D/libEGL(30873): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so 04-28 14:54:40.898: D/libEGL(30873): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
反编译baidumapapi_v2_1_1.jar包发现在 com.baidu.platform.comapi.d.c.j(Unknown Source)这个方法如下:
private static String j(Context paramContext) { String str1 = null; String str2 = "imei.dat"; String str3 = paramContext.getFilesDir().getAbsolutePath() + "/" + str2; File localFile = new File(str3); try { Object localObject; if (!localFile.exists()) { B = false; str1 = k(paramContext); localObject = paramContext.openFileOutput(str2, 32768); ((FileOutputStream)localObject).write(str1.getBytes()); ((FileOutputStream)localObject).close(); } else { B = true; localObject = paramContext.openFileInput(str2); byte[] arrayOfByte = new byte[((FileInputStream)localObject).available()]; ((FileInputStream)localObject).read(arrayOfByte); ((FileInputStream)localObject).close(); str1 = new String(arrayOfByte); int i1 = str1.indexOf('|'); str1 = str1.substring(0, i1); } } catch (Exception localException) { localException.printStackTrace(); } return (String)str1; }
imei.dat这个文件已经存在,推测这个文件已经被创建,所以推测原因是受其他程序的影响。
解决办法:
删除手机上面的其他有关地图测试示例安装程序后,上面的异常情况就消失了。