[Android Software/Hacking General [Developers Only]] android_owl:
Hello xda community,

I'm currently working on a fine-looking snes emulator on base off the snes-emulator-port snes9x from https://github.com/Pretz/SNesoid succesfully (hardly, but, great work btw!). The problem is, that after the app is started and a rom is loaded, the app crashes (goes back to main) and stays there. I suspect an error in the JNI code management. I'm grateful for answers, thank you!

Here's the logcat output:

06-16 12:16:04.492: I/MY_LOG_TAG(230): JNI_OnLoad

06-16 12:16:04.672: D/MY_LOG_TAG(230): Found ROM file header (and ignored it).

06-16 12:16:05.972: D/MY_LOG_TAG(230): "SUPER MARIOWORLD" [checksum ok] LoROM, 4Mbits, Type: ROM+RAM+BAT, Mode: 20, TV: NTSC, S-RAM: 2Kb, ROMId: ???? Company: ??

06-16 12:16:06.952: D/dalvikvm(230): GC freed 2491 objects / 154736 bytes in 329ms

06-16 12:16:07.052: W/dalvikvm(230): JNI WARNING: expected return type 'I'

06-16 12:16:07.052: W/dalvikvm(230): calling Lcom/androidemu/EmuMedia;.setSurfaceRegion (IIII)V

06-16 12:16:07.052: W/dalvikvm(230): in Lcom/androidemu/Emulator;.setSurfaceRegion (IIII)V (CallStaticIntMethodV)

06-16 12:16:07.052: I/dalvikvm(230): "main" prio=5 tid=3 NATIVE

06-16 12:16:07.062: I/dalvikvm(230): | group="main" sCount=0 dsCount=0 s=N obj=0x4001b268 self=0xbd00

06-16 12:16:07.062: I/dalvikvm(230): | sysTid=230 nice=0 sched=0/0 cgrp=default handle=-1344001384

06-16 12:16:07.062: I/dalvikvm(230): at com.androidemu.Emulator.setSurfaceRegion(Native Method)

06-16 12:16:07.062: I/dalvikvm(230): at com.androidemu.snes.EmulatorActivity.surfaceChanged(EmulatorActivity.java:666)

06-16 12:16:07.062: I/dalvikvm(230): at android.view.SurfaceView.updateWindow(SurfaceView.java:460)

06-16 12:16:07.062: I/dalvikvm(230): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:287)

06-16 12:16:07.062: I/dalvikvm(230): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)

06-16 12:16:07.082: I/dalvikvm(230): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)

06-16 12:16:07.082: I/dalvikvm(230): at android.view.View.draw(View.java:6538)

06-16 12:16:07.082: I/dalvikvm(230): at android.widget.FrameLayout.draw(FrameLayout.java:352)

06-16 12:16:07.082: I/dalvikvm(230): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)

06-16 12:16:07.082: I/dalvikvm(230): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)

06-16 12:16:07.092: I/dalvikvm(230): at android.view.View.draw(View.java:6538)

06-16 12:16:07.092: I/dalvikvm(230): at android.widget.FrameLayout.draw(FrameLayout.java:352)

06-16 12:16:07.092: I/dalvikvm(230): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)

06-16 12:16:07.112: I/dalvikvm(230): at android.view.ViewRoot.draw(ViewRoot.java:1349)

06-16 12:16:07.112: I/dalvikvm(230): at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)

06-16 12:16:07.122: I/dalvikvm(230): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)

06-16 12:16:07.122: I/dalvikvm(230): at android.os.Handler.dispatchMessage(Handler.java:99)

06-16 12:16:07.122: I/dalvikvm(230): at android.os.Looper.loop(Looper.java:123)

06-16 12:16:07.122: I/dalvikvm(230): at android.app.ActivityThread.main(ActivityThread.java:4363)

06-16 12:16:07.122: I/dalvikvm(230): at java.lang.reflect.Method.invokeNative(Native Method)

06-16 12:16:07.122: I/dalvikvm(230): at java.lang.reflect.Method.invoke(Method.java:521)

06-16 12:16:07.122: I/dalvikvm(230): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)

06-16 12:16:07.122: I/dalvikvm(230): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

06-16 12:16:07.122: I/dalvikvm(230): at dalvik.system.NativeStart.main(Native Method)

06-16 12:16:07.132: E/dalvikvm(230): VM aborting

06-16 12:16:07.282: I/DEBUG(28): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

06-16 12:16:07.282: I/DEBUG(28): Build fingerprint: 'generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys'

06-16 12:16:07.282: I/DEBUG(28): pid: 230, tid: 230 >>> com.androidemu.snes:emulator <<<

06-16 12:16:07.293: I/DEBUG(28): signal 11 (SIGSEGV), fault addr deadd00d

06-16 12:16:07.293: I/DEBUG(28): r0 00000354 r1 afe1331d r2 0000000c r3 deadd00d

06-16 12:16:07.293: I/DEBUG(28): r4 00000026 r5 43036270 r6 0011efa8 r7 41ae1bdc

06-16 12:16:07.293: I/DEBUG(28): r8 000000e0 r9 000000ac 10 00000000 fp 00000000

06-16 12:16:07.293: I/DEBUG(28): ip ad080160 sp be92f880 lr afe142dd pc ad035452 cpsr 20000030

06-16 12:16:07.861: I/DEBUG(28): #00 pc 00035452 /system/lib/libdvm.so

06-16 12:16:07.871: I/DEBUG(28): #01 pc 00027a98 /system/lib/libdvm.so

06-16 12:16:07.871: I/DEBUG(28): #02 pc 00028820 /system/lib/libdvm.so

06-16 12:16:07.881: I/DEBUG(28): #03 pc 0002c35e /system/lib/libdvm.so

06-16 12:16:07.881: I/DEBUG(28): #04 pc 00001758 /data/data/com.androidemu.snes/lib/libemu.so

06-16 12:16:07.881: I/DEBUG(28): #05 pc 00001804 /data/data/com.androidemu.snes/lib/libemu.so

06-16 12:16:07.891: I/DEBUG(28): #06 pc 00002028 /data/data/com.androidemu.snes/lib/libemu.so

06-16 12:16:07.891: I/DEBUG(28): #07 pc 0000f1f4 /system/lib/libdvm.so

06-16 12:16:07.891: I/DEBUG(28): code around pc:

06-16 12:16:07.891: I/DEBUG(28): ad035440 4808ecb6 6b9b5823 d0002b00 4b064798

06-16 12:16:07.891: I/DEBUG(28): ad035450 701c2426 ed28f7d9 0004ab1c fffe57c4

06-16 12:16:07.891: I/DEBUG(28): ad035460 fffe8c30 00000354 deadd00d b510b40e

06-16 12:16:07.891: I/DEBUG(28): code around lr:

06-16 12:16:07.891: I/DEBUG(28): afe142cc 220ce008 2b005eab 1c28d003 47889901

06-16 12:16:07.891: I/DEBUG(28): afe142dc 35544306 d5f43f01 2c006824 b003d1ee

06-16 12:16:07.891: I/DEBUG(28): afe142ec bdf01c30 00024b44 000000b4 1c0fb5f0

06-16 12:16:07.891: I/DEBUG(28): stack:

06-16 12:16:07.891: I/DEBUG(28): be92f840 00000015

06-16 12:16:07.891: I/DEBUG(28): be92f844 afe1334d /system/lib/libc.so

06-16 12:16:07.891: I/DEBUG(28): be92f848 afe3902c /system/lib/libc.so

06-16 12:16:07.891: I/DEBUG(28): be92f84c afe38fd8 /system/lib/libc.so

06-16 12:16:07.891: I/DEBUG(28): be92f850 00000000

06-16 12:16:07.902: I/DEBUG(28): be92f854 afe142dd /system/lib/libc.so

06-16 12:16:07.902: I/DEBUG(28): be92f858 0000bd00 [heap]

06-16 12:16:07.902: I/DEBUG(28): be92f85c afe1331d /system/lib/libc.so

06-16 12:16:07.902: I/DEBUG(28): be92f860 41ae1bdc /dev/ashmem/dalvik-LinearAlloc (deleted)

06-16 12:16:07.902: I/DEBUG(28): be92f864 ad07ff50 /system/lib/libdvm.so

06-16 12:16:07.902: I/DEBUG(28): be92f868 43036270 /data/dalvik-cache/data@app@com.androidemu.snes.apk@classes.dex

06-16 12:16:07.902: I/DEBUG(28): be92f86c 0011efa8 [heap]

06-16 12:16:07.902: I/DEBUG(28): be92f870 41ae1bdc /dev/ashmem/dalvik-LinearAlloc (deleted)

06-16 12:16:07.902: I/DEBUG(28): be92f874 afe1337f /system/lib/libc.so

06-16 12:16:07.902: I/DEBUG(28): be92f878 df002777

06-16 12:16:07.902: I/DEBUG(28): be92f87c e3a070ad

06-16 12:16:07.902: I/DEBUG(28): #00 be92f880 41ae1bdc /dev/ashmem/dalvik-LinearAlloc (deleted)

06-16 12:16:07.902: I/DEBUG(28): be92f884 ad027a9d /system/lib/libdvm.so

06-16 12:16:07.902: I/DEBUG(28): #01 be92f888 41ae1bdc /dev/ashmem/dalvik-LinearAlloc (deleted)

06-16 12:16:07.902: I/DEBUG(28): be92f88c ad028825 /system/lib/libdvm.so

06-16 12:16:08.592: D/Zygote(30): Process 230 terminated by signal (11)

The native *.so files are build with a few warnings like:

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'

D:\workspaces\SNesoid\SNesoid/sneslib_comp/font.h:144: warning: deprecated conve

rsion from string constant to 'char*'