I am working on the Android version of my app and I am stuck on one point.
I have implemented ads on my app and have added them accordingly. It works fine on Android devices and is not causing errors or crashes. However, the problem comes when I try to close the app by using the back button on the Android device. I have implemented keyBackClicked* and invoked theCCDirector::end()* function.
void MainMenu::keyBackClicked() {
CCDirector::sharedDirector() -> end();
}
The app closes fine (although with a bit of delay). However, when I try to open the app again, it crashes and logs this error:
W/jdwp ( 7555): Debugger is telling the VM to exit with code=1
I/dalvikvm( 7555): GC lifetime allocation: 10222 bytes
F/libc ( 7555): Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1)
I/DEBUG ( 7323): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 7323): Build fingerprint: 'acer/a500_ww_gen1/picasso:4.0.3/IML74K/1333032611:user/release-keys'
I/DEBUG ( 7323): pid: 7555, tid: 7561 >>> com.roomcandygames.gogofarming <<<
I/DEBUG ( 7323): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000008
I/DEBUG ( 7323): r0 00000000 r1 00001000 r2 5b8e1ac9 r3 594b9d5c
I/DEBUG ( 7323): r4 00000000 r5 513b6000 r6 513b60f0 r7 00000000
I/DEBUG ( 7323): r8 00000012 r9 00001000 10 5ba6ab3c fp 0000000c
I/DEBUG ( 7323): ip 408be0a8 sp 594b9d48 lr 40079c13 pc 5b8e1acc cpsr 40000030
I/DEBUG ( 7323): d0 42c8000042bf6e2e d1 3ff0000000658488
I/DEBUG ( 7323): d2 437e8000000000fe d3 000000003f000000
I/DEBUG ( 7323): d4 000001fd00000000 d5 3fe999999999999a
I/DEBUG ( 7323): d6 006a0ff000000000 d7 0000005f4e1e9f14
I/DEBUG ( 7323): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 7323): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 7323): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 7323): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 7323): scr 80000012
I/DEBUG ( 7323):
I/DEBUG ( 7323): #00 pc 00119acc /data/data/com.roomcandygames.gogofarming/lib/libgogofarming.so (_ZN7cocos2d8BitmapDCD1Ev)
I/DEBUG ( 7323): #01 pc 0001ec10 /system/lib/libc.so (__cxa_finalize)
I/DEBUG ( 7323): #02 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #03 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #04 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #05 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #06 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #07 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #08 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #09 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #10 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #11 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #12 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #13 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #14 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #15 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #16 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #17 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #18 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #19 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #20 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #21 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #22 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #23 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #24 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #25 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #26 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #27 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #28 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #29 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #30 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323): #31 pc 0001efa8 /system/lib/libc.so (exit)
I/DEBUG ( 7323):
I/DEBUG ( 7323): code around pc:
I/DEBUG ( 7323): 5b8e1aac 47708ac0 47706980 47702000 47706840 ..pG.ipG. pG@hpG
I/DEBUG ( 7323): 5b8e1abc 47702000 47702000 46c04770 1c04b510 . pG. pGpG.F....
I/DEBUG ( 7323): 5b8e1acc 28006880 f0f6d001 1c20eea2 46c0bd10 .h.(...... ....F
I/DEBUG ( 7323): 5b8e1adc 4b09b510 447b1c04 3308681b 69c06003 ...K..{D.h.3.`.i
I/DEBUG ( 7323): 5b8e1aec d0032800 ee92f0f6 61e32300 f7dc1c20 .(.......#.a ...
I/DEBUG ( 7323):
I/DEBUG ( 7323): code around lr:
I/DEBUG ( 7323): 40079bf0 ecf2f7ed f846b930 46490c0c 22014628 ....0.F...IF(F."
I/DEBUG ( 7323): 40079c00 eceaf7ed 4650b11f 47889903 9a03e001 ......PF...G....
I/DEBUG ( 7323): 40079c10 3e0c4790 38fff118 682dd5d6 d1cd2d00 .G.>...8..-h.-..
I/DEBUG ( 7323): 40079c20 f8dfb9c7 44fcc04c 3000f8dc f8cc1e58 ....L..D...0X...
I/DEBUG ( 7323): 40079c30 b9780000 58a14a0d e0046808 46496805 ..x..J.X.h...hIF
I/DEBUG ( 7323):
I/DEBUG ( 7323): stack:
I/DEBUG ( 7323): 594b9d08 7fffffff
I/DEBUG ( 7323): 594b9d0c 400a34c0
I/DEBUG ( 7323): 594b9d10 01323000 [heap]
I/DEBUG ( 7323): 594b9d14 01323020 [heap]
I/DEBUG ( 7323): 594b9d18 0110eb58 [heap]
I/DEBUG ( 7323): 594b9d1c 400a3498
I/DEBUG ( 7323): 594b9d20 01059aa7 [heap]
I/DEBUG ( 7323): 594b9d24 594b9d48
I/DEBUG ( 7323): 594b9d28 01275318 [heap]
I/DEBUG ( 7323): 594b9d2c 01275328 [heap]
I/DEBUG ( 7323): 594b9d30 00000080
I/DEBUG ( 7323): 594b9d34 400a3474
I/DEBUG ( 7323): 594b9d38 01275320 [heap]
I/DEBUG ( 7323): 594b9d3c 00000008
I/DEBUG ( 7323): 594b9d40 df0027ad
I/DEBUG ( 7323): 594b9d44 00000000
I/DEBUG ( 7323): #00 594b9d48 4009e55c /system/lib/libc.so
I/DEBUG ( 7323): 594b9d4c 40079c13 /system/lib/libc.so
I/DEBUG ( 7323): #01 594b9d50 01323000 [heap]
I/DEBUG ( 7323): 594b9d54 594b9d5c
I/DEBUG ( 7323): 594b9d58 01059aa7 [heap]
I/DEBUG ( 7323): 594b9d5c 5b8e1ac9 /data/data/com.roomcandygames.gogofarming/lib/libgogofarming.so
I/DEBUG ( 7323): 594b9d60 5ba6ab3c
I/DEBUG ( 7323): 594b9d64 5ba64000 /data/data/com.roomcandygames.gogofarming/lib/libgogofarming.so
I/DEBUG ( 7323): 594b9d68 0110ebf0 [heap]
I/DEBUG ( 7323): 594b9d6c 00000001
I/DEBUG ( 7323): 594b9d70 013272f0 [heap]
I/DEBUG ( 7323): 594b9d74 00000008
I/DEBUG ( 7323): 594b9d78 4087acdd /system/lib/libdvm.so
I/DEBUG ( 7323): 594b9d7c 0110eb58 [heap]
I/DEBUG ( 7323): 594b9d80 00000004
I/DEBUG ( 7323): 594b9d84 01059aa7 [heap]
I/DEBUG ( 7323): 594b9d88 01059aa7 [heap]
I/DEBUG ( 7323): 594b9d8c 40079fad /system/lib/libc.so
After sifting through the code, I concluded that the app crashes when it tries to redraw the ad views. On the CCDirector Class Reference, it states that end* doesn’t remove the OpenGL view from its parent and I have to do it manually. I believe this is the cause of the problem as the ad views are added apart from the openGL view and is not being destroyed whenend()* is invoked.
So here are my questions:
- How would I destroy the ad views when *end()* is invoked?
- Is there a better way to end the app when the back button is pressed?
Thanks in advance.