今天用 android studio 寫程序踩到這個(gè)詭異的坑:
首先介紹使用的開發(fā)工具和環(huán)境:android studio
測(cè)試機(jī)型:紅米note2: android 5.0.2
是這樣的:筆者程序中寫的這個(gè)頁面中上方是一個(gè)地圖(高德地圖)艾凯,下方是一個(gè)listview移怯,展示地圖中的相關(guān)數(shù)據(jù)锉矢,然后今天要改造這個(gè)listview為expandableListViewV齿风,吭哧吭哧寫完了肉渴,高高興興等華麗麗的變化,然而 圖樣圖森破 泡徙,點(diǎn)進(jìn)這個(gè)有地圖的頁面该肴,顯示黑屏,卡了好幾秒障陶,直接閃退回登錄界面滋恬,然后報(bào)了下方的錯(cuò),真是抱究。恢氯。。招誰惹誰了媳维。酿雪。。對(duì)了詭異的事還沒說:不管你怎么修改代碼侄刽,再進(jìn)來這個(gè)頁面就是這樣了,接下來重點(diǎn)來了朋凉,我試著卸載掉這個(gè)app州丹,然后重新編譯安裝,又可以運(yùn)行地圖的界面了,然而墓毒,重新隨便改下界面的布局吓揪,再instance Run一下,爆炸所计,重復(fù)上面的報(bào)錯(cuò)了柠辞。當(dāng)然,看報(bào)錯(cuò)信息應(yīng)該跟jni相關(guān)主胧,試著換個(gè)手機(jī)叭首,同樣會(huì)出現(xiàn)一眼改的問題,然后踪栋,試著關(guān)閉instance Run 焙格,結(jié)果還是老樣子(詭異的是之前開發(fā)這個(gè)界面就沒出現(xiàn)過這個(gè)情況,so庫是高德開放api提供的夷都,且一直沒有更換jni放置目錄眷唉,而且檢查data/app/應(yīng)用包名/lib/arm/編譯打包進(jìn)的so庫無異常,猜想是更新了android studio 和gradle囤官?)冬阳,現(xiàn)在問題還沒解決,暫時(shí)先在這記錄下党饮。(解決了再更新)
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 :筆者今天在開發(fā)另外的安卓程序中使用高德地圖api再一次遇到這個(gè)問題摩泪,不過今天有一個(gè)意外的發(fā)現(xiàn):"Your app does not have the latest code changes because it was restarted manually. Please run from IDE instead",如下圖劫谅,是再次運(yùn)行出問題時(shí)的系統(tǒng)彈出框提示
這次用這段話google了一下下见坑,然后找到一個(gè)相關(guān)的鏈接啦:http://stackoverflow.com/questions/36872586/android-studio-your-app-does-not-have-the-latest-code-changes ,也許是這個(gè)原因,也許不是捏检,先更新記錄下啦先荞驴。
根據(jù)stackoverflow中的討論:得出的是android studio 的 instance run 的時(shí)候,app被手動(dòng)重啟贯城,導(dǎo)致instance run 部署代碼異常熊楼,估計(jì)跟著高德地圖的jni代碼部署也異常了。
解決方案:根據(jù)stackoverflow中的能犯,Run>Clean and Re-Run 鲫骗,這跟我問題描述中的解決方案一樣。