I am trying to return a String from .java file to my game, but All I am getting is some SIG error. The method is declared in s4e as follows -
const char* s3eExtentionGetRegisterationID() run_on_os_thread
I modified s3eExtension_platform.cpp to edit the JNI method like this -
const char* s3eExtensionGetRegisterationID_platform()
{
JNIEnv* env = s3eEdkJNIGetEnv();
JavaString res((jstring)env->CallObjectMethod(g_Obj, g_s3eExtensionGetRegisterationID);
return getCString((jstring)res);
}
Is there anything else I'd need to do, in order to get the string. The error I am getting is -
09-30 20:45:28.183: A/libc(2662): Fatal signal 11 (SIGSEGV) at 0xf400001d (code=1), thread 2678 (Thread-787)
09-30 20:45:28.293: I/DEBUG(1976): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-30 20:45:28.293: I/DEBUG(1976): Build fingerprint: 'SEMC/LT22i_1261-7821/LT22i:4.1.2/6.2.A.1.100/m_v_zg:user/release-keys'
09-30 20:45:28.293: I/DEBUG(1976): pid: 2662, tid: 2678, name: Thread-787 >>> com.creator.test <<<
09-30 20:45:28.293: I/DEBUG(1976): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr f400001d
09-30 20:45:28.393: I/DEBUG(1976): r0 0bffffe2 r1 00000000 r2 00000000 r3 f400001d
09-30 20:45:28.393: I/DEBUG(1976): r4 59c01590 r5 59c01590 r6 00000000 r7 f400001d
09-30 20:45:28.393: I/DEBUG(1976): r8 5a04ff94 r9 00000004 sl 59c01594 fp 00000000
09-30 20:45:28.393: I/DEBUG(1976): ip 00000000 sp 5a04fda8 lr 5c423564 pc 5c4566ec cpsr 60000010
09-30 20:45:28.393: I/DEBUG(1976): d0 0000000000000000 d1 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d2 0000000000000000 d3 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d4 0066007200750053 d5 0054006500630061
09-30 20:45:28.393: I/DEBUG(1976): d6 0075007400780065 d7 0000000000650072
09-30 20:45:28.393: I/DEBUG(1976): d8 0000000000000000 d9 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d10 0000000000000000 d11 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d12 0000000000000000 d13 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d14 0000000000000000 d15 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d16 0000000000000000 d17 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d18 0000000000000000 d19 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d20 0000000000000000 d21 3ff0000000000000
09-30 20:45:28.393: I/DEBUG(1976): d22 8000000000000000 d23 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d24 0000000000000000 d25 8000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d26 3ff0000000000000 d27 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d28 0000000000000005 d29 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): d30 0000000000000000 d31 0000000000000000
09-30 20:45:28.393: I/DEBUG(1976): scr 20000010
09-30 20:45:28.393: I/DEBUG(1976): backtrace:
09-30 20:45:28.393: I/DEBUG(1976): #00 pc 000346ec <unknown>
09-30 20:45:28.393: I/DEBUG(1976): #01 pc 00001560 <unknown>
09-30 20:45:28.393: I/DEBUG(1976): stack:
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd68 59c01314
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd6c 5c458aa4
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd70 59c01314
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd74 00000052
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd78 59c00fc0
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd7c 5c455f00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd80 5a04fd98
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd84 5d2356e7 /data/data/com.creator.test/lib/libtest.so
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd88 5a04fd98
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd8c 5d23340b /data/data/com.creator.test/lib/libtest.so
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd90 5a04fd98
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd94 5d232aa8 /data/data/com.creator.test/lib/libtest.so
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd98 59c014f8
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd9c 5a04ff00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fda0 df0027ad
09-30 20:45:28.393: I/DEBUG(1976): 5a04fda4 00000000
09-30 20:45:28.393: I/DEBUG(1976): #00 5a04fda8 00000001
09-30 20:45:28.393: I/DEBUG(1976): ........ ........
09-30 20:45:28.393: I/DEBUG(1976): #01 5a04fda8 00000001
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdac 5a04ff00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdb0 5a04fe00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdb4 5a04ff80
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdb8 5a04ff94
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdbc 00000000
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdc0 00000000
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdc4 5c4237fc
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdc8 00000000
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdcc 5c423058
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdd0 00000000
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdd4 00000001
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdd8 5a04ff00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fddc 5a04fe00
09-30 20:45:28.393: I/DEBUG(1976): 5a04fde0 5a04ff80
09-30 20:45:28.393: I/DEBUG(1976): 5a04fde4 5a04ff94
09-30 20:45:28.393: I/DEBUG(1976): memory near r0:
09-30 20:45:28.393: I/DEBUG(1976): 0bffffc0 ffffffff ffffffff ffffffff ffffffff ................
09-30 20:45:28.393: I/DEBUG(1976): 0bffffd0 ffffffff ffffffff ffffffff ffffffff ................
09-30 20:45:28.393: I/DEBUG(1976): 0bffffe0 ffffffff ffffffff ffffffff ffffffff ................
09-30 20:45:28.393: I/DEBUG(1976): 0bfffff0 ffffffff ffffffff ffffffff ffffffff ................
09-30 20:45:28.393: I/DEBUG(1976): 0c000000 ffffffff ffffffff ffffffff ffffffff ................
09-30 20:45:28.393: I/DEBUG(1976): memory near r4:
09-30 20:45:28.393: I/DEBUG(1976): 59c01570 59c018a8 59c018e0 5f149ff8 5f149ff8 ...Y...Y..._..._
09-30 20:45:28.393: I/DEBUG(1976): 59c01580 5f14a000 00000020 5f14a128 59c01590 ..._ ...(.._...Y
09-30 20:45:28.393: I/DEBUG(1976): 59c01590 5c46105c 5c461070 00001008 00000000 \.F\p.F\........
09-30 20:45:28.393: I/DEBUG(1976): 59c015a0 00000000 00000000 00000000 00000006 ................
09-30 20:45:28.393: I/DEBUG(1976): 59c015b0 00000000 59c01890 00000000 00000000 .......Y........
09-30 20:45:28.393: I/DEBUG(1976): memory near r5:
09-30 20:45:28.393: I/DEBUG(1976): 59c01570 59c018a8 59c018e0 5f149ff8 5f149ff8 ...Y...Y..._..._
09-30 20:45:28.393: I/DEBUG(1976): 59c01580 5f14a000 00000020 5f14a128 59c01590 ..._ ...(.._...Y
09-30 20:45:28.393: I/DEBUG(1976): 59c01590 5c46105c 5c461070 00001008 00000000 \.F\p.F\........
09-30 20:45:28.393: I/DEBUG(1976): 59c015a0 00000000 00000000 00000000 00000006 ................
09-30 20:45:28.393: I/DEBUG(1976): 59c015b0 00000000 59c01890 00000000 00000000 .......Y........
09-30 20:45:28.393: I/DEBUG(1976): memory near r8:
09-30 20:45:28.393: I/DEBUG(1976): 5a04ff74 5c44c0fc 00000005 00000009 76677261 ..D\........argv
09-30 20:45:28.393: I/DEBUG(1976): 5a04ff84 005d315b 00000000 5c4536b4 42494000 [1]......6E\.@IB
09-30 20:45:28.393: I/DEBUG(1976): 5a04ff94 5e0119a8 5e011968 5d26d630 00000000 ...^h..^0.&]....
09-30 20:45:28.393: I/DEBUG(1976): 5a04ffa4 00000000 00000000 5c422048 5e0119a8 ........H B\...^
09-30 20:45:28.393: I/DEBUG(1976): 5a04ffb4 00000000 5e0119a8 5d2335e9 5d26d630 .......^.5#]0.&]
09-30 20:45:28.393: I/DEBUG(1976): memory near sl:
09-30 20:45:28.393: I/DEBUG(1976): 59c01574 59c018e0 5f149ff8 5f149ff8 5f14a000 ...Y..._..._..._
09-30 20:45:28.393: I/DEBUG(1976): 59c01584 00000020 5f14a128 59c01590 5c46105c ...(.._...Y\.F\
09-30 20:45:28.393: I/DEBUG(1976): 59c01594 5c461070 00001008 00000000 00000000 p.F\............
09-30 20:45:28.393: I/DEBUG(1976): 59c015a4 00000000 00000000 00000006 00000000 ................
09-30 20:45:28.393: I/DEBUG(1976): 59c015b4 59c01890 00000000 00000000 00000000 ...Y............
09-30 20:45:28.393: I/DEBUG(1976): memory near sp:
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd88 5a04fd98 5d23340b 5a04fd98 5d232aa8 ...Z.4#]...Z.*#]
09-30 20:45:28.393: I/DEBUG(1976): 5a04fd98 59c014f8 5a04ff00 df0027ad 00000000 ...Y...Z.'......
09-30 20:45:28.393: I/DEBUG(1976): 5a04fda8 00000001 5a04ff00 5a04fe00 5a04ff80 .......Z...Z...Z
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdb8 5a04ff94 00000000 00000000 5c4237fc ...Z.........7B\
09-30 20:45:28.393: I/DEBUG(1976): 5a04fdc8 00000000 5c423058 00000000 00000001 ....X0B\........
09-30 20:45:28.393: I/DEBUG(1976): code around pc:
09-30 20:45:28.393: I/DEBUG(1976): 5c4566cc 11a01006 11a02005 1bfffa7d e1a00004 ..... ..}.......
09-30 20:45:28.393: I/DEBUG(1976): 5c4566dc e8bd4070 e12fff1e e1a03000 e1e00000 p@..../..0......
09-30 20:45:28.393: I/DEBUG(1976): 5c4566ec e4d32001 e3520000 1afffffc e0800003 . ....R.........
09-30 20:45:28.393: I/DEBUG(1976): 5c4566fc e12fff1e e92d0030 e1a03000 ea000000 ../.0.-..0......
09-30 20:45:28.403: I/DEBUG(1976): 5c45670c e2833001 e5d3c000 e35c0000 1afffffb .0........\.....
09-30 20:45:28.403: I/DEBUG(1976): code around lr:
09-30 20:45:28.403: I/DEBUG(1976): 5c423544 e513900c e085a009 e59a1008 e1a0300a .............0..
09-30 20:45:28.403: I/DEBUG(1976): 5c423554 e3510000 1a000029 e1a00007 eb00cc5f ..Q.)......._...
09-30 20:45:28.403: I/DEBUG(1976): 5c423564 e59a801c e1500008 e1a06000 aa00003b ......P..`..;...
09-30 20:45:28.403: I/DEBUG(1976): 5c423574 e0588000 0a000039 e59a2004 e59a0058 ..X.9.... ..X...
09-30 20:45:28.403: I/DEBUG(1976): 5c423584 e202c007 e35c0001 0a000060 e5902000 ......\.`.... ..
09-30 20:45:28.403: I/DEBUG(1976): memory map around fault addr f400001d:
09-30 20:45:28.403: I/DEBUG(1976): bec60000-bec81000 [stack]
09-30 20:45:28.403: I/DEBUG(1976): (no map for address)
09-30 20:45:28.403: I/DEBUG(1976): ffff0000-ffff1000 [vectors]
09-30 20:45:28.534: I/BootReceiver(2474): Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
09-30 20:45:28.564: I/WindowState(2474): WIN DEATH: Window{420feed8 SurfaceView paused=false}
09-30 20:45:28.574: I/ActivityManager(2474): Process com.creator.test (pid 2662) has died.
09-30 20:45:28.574: W/ActivityManager(2474): Force removing ActivityRecord{42067fb8 com.creator.test/.Main}: app died, no saved state
I forgot that I need to declare these methods too. I thought they are inbuilt in JNI. Just need to add the following lines of code -
static char* g_RetStr;
static int g_RetStrLen = 16384;
struct JavaString
{
jstring _Ref;
JavaString ( const char *Buffer )
{
JNIEnv *env = s3eEdkJNIGetEnv();
_Ref = env->NewStringUTF ( Buffer );
}
JavaString ( jstring Ref )
{
_Ref = Ref;
}
~JavaString()
{
JNIEnv *env = s3eEdkJNIGetEnv();
env->DeleteLocalRef ( _Ref );
}
operator jstring()
{
return _Ref;
}
};
const char* getCString(jstring str)
{
JNIEnv* env = s3eEdkJNIGetEnv();
if (!str)
return NULL;
jboolean free;
const char* res = env->GetStringUTFChars(str, &free);
g_RetStrLen = strlen(res) + 1;
g_RetStr = (char *)s3eEdkReallocOS(g_RetStr, g_RetStrLen);
strcpy(g_RetStr, res);
env->ReleaseStringUTFChars(str, res);
return g_RetStr;
}
//In Init
g_RetStr = (char*)s3eEdkMallocOS(g_RetStrLen);