今天用 android studio 写程序踩到这个诡异的坑:
首先介绍使用的开发工具和环境:android studio
测试机型:红米note2: android 5.0.2
是这样的:笔者程序中写的这个页面中上方是一个地图(高德地图),下方是一个listview,展示地图中的相关数据,然后今天要改造这个listview为expandableListViewV,吭哧吭哧写完了,高高兴兴等华丽丽的变化,然而 图样图森破 ,点进这个有地图的页面,显示黑屏,卡了好几秒,直接闪退回登录界面,然后报了下方的错,真是。。。招谁惹谁了。。。对了诡异的事还没说:不管你怎么修改代码,再进来这个页面就是这样了,接下来重点来了,我试着卸载掉这个app,然后重新编译安装,又可以运行地图的界面了,然而,重新随便改下界面的布局,再instance Run一下,爆炸,重复上面的报错了。当然,看报错信息应该跟jni相关,试着换个手机,同样会出现一眼改的问题,然后,试着关闭instance Run ,结果还是老样子(诡异的是之前开发这个界面就没出现过这个情况,so库是高德开放api提供的,且一直没有更换jni放置目录,而且检查data/app/应用包名/lib/arm/编译打包进的so库无异常,猜想是更新了android studio 和gradle?),现在问题还没解决,暂时先在这记录下。(解决了再更新)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] JNI DETECTED ERROR IN APPLICATION: jarray was NULL
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] in call to GetByteArrayElements
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] from void com.autonavi.amap.mapcore.MapCore.nativeSetInternaltexture(long, byte[], int)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] "GLThread 584" prio=5 tid=39 Runnable
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] | group="main" sCount=0 dsCount=0 obj=0x12d60920 self=0xab8a3cc8
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] | sysTid=9417 nice=0 cgrp=default sched=0/0 handle=0xe510f000
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] | state=R schedstat=( 12297768 7041846 75 ) utm=0 stm=1 core=2 HZ=100
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] | stack=0xdfa0c000-0xdfa0e000 stackSize=1036KB
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] | held mutexes= "mutator lock"(shared held)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #00 pc 00004d44 /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #01 pc 002440f1 /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiPKcPNS_6mirror9ArtMethodE+68)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #02 pc 0022981d /system/lib/libart.so (_ZNK3art6Thread4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+144)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #03 pc 000b026d /system/lib/libart.so (_ZN3artL8JniAbortEPKcS1_+556)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #04 pc 000b0985 /system/lib/libart.so (_ZN3art9JniAbortFEPKcS1_z+60)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #05 pc 000b31f5 /system/lib/libart.so (_ZN3art11ScopedCheck5CheckEbPKcz.constprop.141+1812)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #06 pc 000bc27d /system/lib/libart.so (_ZN3art8CheckJNI20GetByteArrayElementsEP7_JNIEnvP11_jbyteArrayPh+44)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #07 pc 0000a091 /data/app/com.lanqian.skxcpt-1/lib/arm/libgdinamapv4sdk752ex.so (Java_com_autonavi_amap_mapcore_MapCore_nativeSetInternaltexture+20)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] native: #08 pc 000e04b9 /data/data/com.lanqian.skxcpt/cache/slice-AMap_3DMap_V3.3.2_20160525_a1f12488cb9e57a151d80c3b3d4a08c03985fe7b-classes.dex (Java_com_autonavi_amap_mapcore_MapCore_nativeSetInternaltexture__J_3BI+128)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at com.autonavi.amap.mapcore.MapCore.nativeSetInternaltexture(Native method)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at com.autonavi.amap.mapcore.MapCore.setInternaltexture(MapCore.java:135)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at com.amap.api.mapcore.util.u.e(GLMapResManager.java:462)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at com.amap.api.mapcore.util.c.r(AMapDelegateImp.java:1118)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] - locked <0x2cb31f19> (a com.amap.api.mapcore.util.c)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at com.amap.api.mapcore.util.c.onSurfaceCreated(AMapDelegateImp.java:4320)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1548)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70] at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)
08-18 16:03:41.832 9298-9417/com.lanqian.skxcpt A/art: art/runtime/check_jni.cc:70]
08-18 16:03:41.833 9298-9417/com.lanqian.skxcpt A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 9417 (GLThread 584)
2016-09-08 :笔者今天在开发另外的安卓程序中使用高德地图api再一次遇到这个问题,不过今天有一个意外的发现:"Your app does not have the latest code changes because it was restarted manually. Please run from IDE instead",如下图,是再次运行出问题时的系统弹出框提示
这次用这段话google了一下下,然后找到一个相关的链接啦:http://stackoverflow.com/questions/36872586/android-studio-your-app-does-not-have-the-latest-code-changes ,也许是这个原因,也许不是,先更新记录下啦先。
根据stackoverflow中的讨论:得出的是android studio 的 instance run 的时候,app被手动重启,导致instance run 部署代码异常,估计跟着高德地图的jni代码部署也异常了。
解决方案:根据stackoverflow中的,Run>Clean and Re-Run ,这跟我问题描述中的解决方案一样。