使用AdMobs和JNI实施插页式广告

时间:2014-02-10 22:04:25

标签: java c++ java-native-interface admob interstitial

是否可以通过从C ++调用Java方法来启动插页式广告? 我想要做的是在我的游戏中的某个点调用java方法,并从那里开始插页式广告。问题是它直接崩溃了应用程序。

我已经实现了其他几种java方法来处理提交成就,排行榜得分等等。但是调用插页式广告会导致应用崩溃。

以下是我的工作:

活动顶部:

InterstitialAd interstitial;

在onCreate方法

// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(MY_AD_UNIT_ID);

// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();

// Begin loading your interstitial.
interstitial.loadAd(adRequest);

实现了从C ++代码调用的java方法:

public void googleDisplayAd()
{       
    if (interstitial.isLoaded())
    {
        Log.v("googleplay", "interstitial loaded");
        interstitial.show();
    }
}

它到了interstitial.isLoaded()并在那里崩溃。

以下是包含崩溃信息的文本上传:http://pastebin.com/XRT5uBxq

02-09 23:16:40.828: I/DEBUG(8990): [02-09 23:16:40.844]
02-09 23:16:40.828: I/DEBUG(8990): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-09 23:16:40.828: I/DEBUG(8990): Build fingerprint: 'lge/fx3s_spr_us/fx3:4.1.2/JZO54K/LS720ZV6.1383787089:user/release-keys'
02-09 23:16:40.828: I/DEBUG(8990): pid: 21335, tid: 21345, name: FinalizerDaemon  >>> com.ronkrepps.chaindrop <<<
02-09 23:16:40.828: I/DEBUG(8990): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000050
02-09 23:16:41.249: I/DEBUG(8990):     r0 60ad71c8  r1 20600001  r2 60ad71c8  r3 00000051
02-09 23:16:41.249: I/DEBUG(8990):     r4 5747f7f0  r5 5d4cbaf0  r6 00000000  r7 51878f30
02-09 23:16:41.249: I/DEBUG(8990):     r8 5db19c80  r9 51878f28  sl 5d4cbb00  fp 5db19c94
02-09 23:16:41.249: I/DEBUG(8990):     ip 4032aaa1  sp 5db19c78  lr 4032aab9  pc 00000050  cpsr a0000030
02-09 23:16:41.249: I/DEBUG(8990):     d0  00000001000f0003  d1  0000000000000000
02-09 23:16:41.249: I/DEBUG(8990):     d2  0000000000000000  d3  0000000057477fc0
02-09 23:16:41.249: I/DEBUG(8990):     d4  ffffffff00000001  d5  0000000012000008
02-09 23:16:41.249: I/DEBUG(8990):     d6  01080ff000020000  d7  000000304e47d120
02-09 23:16:41.249: I/DEBUG(8990):     d8  0000000000000000  d9  0000000000000000
02-09 23:16:41.249: I/DEBUG(8990):     d10 0000000000000000  d11 0000000000000000
02-09 23:16:41.249: I/DEBUG(8990):     d12 0000000000000000  d13 0000000000000000
02-09 23:16:41.249: I/DEBUG(8990):     d14 0000000000000000  d15 0000000000000000
02-09 23:16:41.249: I/DEBUG(8990):     d16 0000000057477b70  d17 0000000100030101
02-09 23:16:41.259: I/DEBUG(8990):     d18 41483f7800000000  d19 c0000000400a60b0
02-09 23:16:41.259: I/DEBUG(8990):     d20 401a6a9c00000020  d21 00000bbbbe8958b8
02-09 23:16:41.259: I/DEBUG(8990):     d22 41cf15d000000404  d23 0000003533333132
02-09 23:16:41.259: I/DEBUG(8990):     d24 3fd99a27ad32ddf5  d25 3fe555b0aaeac752
02-09 23:16:41.259: I/DEBUG(8990):     d26 0000000000000000  d27 0000000000000000
02-09 23:16:41.259: I/DEBUG(8990):     d28 0000000000000005  d29 0000000000000000
02-09 23:16:41.259: I/DEBUG(8990):     d30 0000000000000000  d31 0000000000000000
02-09 23:16:41.259: I/DEBUG(8990):     scr 20000010
02-09 23:16:41.259: I/DEBUG(8990): backtrace:
02-09 23:16:41.259: I/DEBUG(8990):     #00  pc 00000050  <unknown>
02-09 23:16:41.259: I/DEBUG(8990):     #01  pc 00065ab7  /system/lib/libandroid_runtime.so
02-09 23:16:41.259: I/DEBUG(8990):     #02  pc 0001fcf0  /system/lib/libdvm.so (dvmPlatformInvoke+112)
02-09 23:16:41.259: I/DEBUG(8990):     #03  pc 0004ea51  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+360)
02-09 23:16:41.259: I/DEBUG(8990):     #04  pc 000291a0  /system/lib/libdvm.so
02-09 23:16:41.259: I/DEBUG(8990):     #05  pc 0002d968  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
02-09 23:16:41.259: I/DEBUG(8990):     #06  pc 00060059  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
02-09 23:16:41.259: I/DEBUG(8990):     #07  pc 00060083  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
02-09 23:16:41.259: I/DEBUG(8990):     #08  pc 000554ab  /system/lib/libdvm.so
02-09 23:16:41.269: I/DEBUG(8990):     #09  pc 00012f30  /system/lib/libc.so (__thread_entry+48)
02-09 23:16:41.269: I/DEBUG(8990):     #10  pc 00012688  /system/lib/libc.so (pthread_create+172)
02-09 23:16:41.269: I/DEBUG(8990): stack:
02-09 23:16:41.269: I/DEBUG(8990):          5db19c38  57233fe0  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c3c  408f5c07  /system/lib/libdvm.so
02-09 23:16:41.269: I/DEBUG(8990):          5db19c40  40951578  /system/lib/libdvm.so
02-09 23:16:41.269: I/DEBUG(8990):          5db19c44  5d4cbaf0  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c48  5d4cbaf0  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c4c  00000000  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c50  51878f70  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c54  4016b8f1  /system/lib/libc.so (dlfree+56)
02-09 23:16:41.269: I/DEBUG(8990):          5db19c58  40951578  /system/lib/libdvm.so
02-09 23:16:41.269: I/DEBUG(8990):          5db19c5c  401a6a9c  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c60  5d4cbaf0  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c64  00000000  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c68  41cfa710  /dev/ashmem/dalvik-heap (deleted)
02-09 23:16:41.269: I/DEBUG(8990):          5db19c6c  5d4cbaf0  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c70  df0027ad  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c74  00000000  
02-09 23:16:41.269: I/DEBUG(8990):     #00  5db19c78  51878f5c  
02-09 23:16:41.269: I/DEBUG(8990):          ........  ........
02-09 23:16:41.269: I/DEBUG(8990):     #01  5db19c78  51878f5c  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c7c  408c2cf4  /system/lib/libdvm.so (dvmPlatformInvoke+116)
02-09 23:16:41.269: I/DEBUG(8990):     #02  5db19c80  51878f24  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c84  00000001  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c88  41cfa710  /dev/ashmem/dalvik-heap (deleted)
02-09 23:16:41.269: I/DEBUG(8990):          5db19c8c  00000000  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c90  00000000  
02-09 23:16:41.269: I/DEBUG(8990):          5db19c94  408f1a55  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+364)
02-09 23:16:41.279: I/DEBUG(8990): memory near r0:
02-09 23:16:41.279: I/DEBUG(8990):     60ad71a8 ff90bcff ffffffff ffffffff 199fffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     60ad71b8 fffffdc4 ffffffff 20cbfeff 00000051  ........... Q...
02-09 23:16:41.279: I/DEBUG(8990):     60ad71c8 5d43c980 4019f5a4 62050670 00000000  ..C]...@p..b....
02-09 23:16:41.279: I/DEBUG(8990):     60ad71d8 00000000 70612f61 ffffffff ffffffff  ....a/ap........
02-09 23:16:41.279: I/DEBUG(8990):     60ad71e8 00010c50 00000000 00024ae4 00000000  P........J......
02-09 23:16:41.279: I/DEBUG(8990): memory near r1:
02-09 23:16:41.279: I/DEBUG(8990):     205fffe0 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     205ffff0 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     20600000 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     20600010 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     20600020 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.279: I/DEBUG(8990): memory near r2:
02-09 23:16:41.279: I/DEBUG(8990):     60ad71a8 ff90bcff ffffffff ffffffff 199fffff  ................
02-09 23:16:41.279: I/DEBUG(8990):     60ad71b8 fffffdc4 ffffffff 20cbfeff 00000051  ........... Q...
02-09 23:16:41.279: I/DEBUG(8990):     60ad71c8 5d43c980 4019f5a4 62050670 00000000  ..C]...@p..b....
02-09 23:16:41.279: I/DEBUG(8990):     60ad71d8 00000000 70612f61 ffffffff ffffffff  ....a/ap........
02-09 23:16:41.279: I/DEBUG(8990):     60ad71e8 00010c50 00000000 00024ae4 00000000  P........J......
02-09 23:16:41.289: I/DEBUG(8990): memory near r4:
02-09 23:16:41.289: I/DEBUG(8990):     5747f7d0 00001682 590a63e1 4032a5e5 00000000  .....c.Y..2@....
02-09 23:16:41.289: I/DEBUG(8990):     5747f7e0 408f18e9 00000100 00000000 00000000  ...@............
02-09 23:16:41.289: I/DEBUG(8990):     5747f7f0 41488440 00000112 00020000 00020000  @.HA............
02-09 23:16:41.289: I/DEBUG(8990):     5747f800 590e8ce9 4005d880 000016b4 590a6fb9  ...Y...@.....o.Y
02-09 23:16:41.289: I/DEBUG(8990):     5747f810 4032aaa1 00000000 408f18e9 00000100  ..2@.......@....
02-09 23:16:41.289: I/DEBUG(8990): memory near r5:
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbad0 408a1368 5d4cbfb8 00000000 00000013  h..@..L]........
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbae0 408a1368 5d4cb298 00000000 00000453  h..@..L]....S...
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbaf0 58c41722 51878f24 5747f5c0 5947f000  "..X$..Q..GW..GY
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbb00 41483e88 00011f0e 5db19da8 00000000  .>HA.......]....
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbb10 5db19ddc 00000007 00000000 408c2e80  ...]...........@
02-09 23:16:41.289: I/DEBUG(8990): memory near r7:
02-09 23:16:41.289: I/DEBUG(8990):     51878f10 51878f40 58c41a00 5747f7f0 00000000  @..Q...X..GW....
02-09 23:16:41.289: I/DEBUG(8990):     51878f20 00000000 20600001 60ad71c8 51878f5c  ......` .q.`\..Q
02-09 23:16:41.289: I/DEBUG(8990):     51878f30 58c41732 5747f5c0 58c41a00 00000000  2..X..GW...X....
02-09 23:16:41.289: I/DEBUG(8990):     51878f40 41cfa710 60ad71c8 51878f80 58c41778  ...A.q.`...Qx..X
02-09 23:16:41.289: I/DEBUG(8990):     51878f50 575790b8 58c41732 00000000 41cfa710  ..WW2..X.......A
02-09 23:16:41.289: I/DEBUG(8990): memory near r8:
02-09 23:16:41.289: I/DEBUG(8990):     5db19c60 5d4cbaf0 00000000 41cfa710 5d4cbaf0  ..L].......A..L]
02-09 23:16:41.289: I/DEBUG(8990):     5db19c70 df0027ad 00000000 51878f5c 408c2cf4  .'......\..Q.,.@
02-09 23:16:41.289: I/DEBUG(8990):     5db19c80 51878f24 00000001 41cfa710 00000000  $..Q.......A....
02-09 23:16:41.289: I/DEBUG(8990):     5db19c90 00000000 408f1a55 51878f24 590a6fb9  ....U..@$..Q.o.Y
02-09 23:16:41.289: I/DEBUG(8990):     5db19ca0 4032aaa1 5d4cbb00 00000000 00000000  ..2@..L]........
02-09 23:16:41.289: I/DEBUG(8990): memory near r9:
02-09 23:16:41.289: I/DEBUG(8990):     51878f08 00000000 00000000 51878f40 58c41a00  ........@..Q...X
02-09 23:16:41.289: I/DEBUG(8990):     51878f18 5747f7f0 00000000 00000000 20600001  ..GW..........`
02-09 23:16:41.289: I/DEBUG(8990):     51878f28 60ad71c8 51878f5c 58c41732 5747f5c0  .q.`\..Q2..X..GW
02-09 23:16:41.289: I/DEBUG(8990):     51878f38 58c41a00 00000000 41cfa710 60ad71c8  ...X.......A.q.`
02-09 23:16:41.289: I/DEBUG(8990):     51878f48 51878f80 58c41778 575790b8 58c41732  ...Qx..X..WW2..X
02-09 23:16:41.289: I/DEBUG(8990): memory near sl:
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbae0 408a1368 5d4cb298 00000000 00000453  h..@..L]....S...
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbaf0 58c41722 51878f24 5747f5c0 5947f000  "..X$..Q..GW..GY
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbb00 41483e88 00011f0e 5db19da8 00000000  .>HA.......]....
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbb10 5db19ddc 00000007 00000000 408c2e80  ...]...........@
02-09 23:16:41.289: I/DEBUG(8990):     5d4cbb20 00000000 00000000 56a0d270 51875300  ........p..V.S.Q
02-09 23:16:41.289: I/DEBUG(8990): memory near fp:
02-09 23:16:41.289: I/DEBUG(8990):     5db19c74 00000000 51878f5c 408c2cf4 51878f24  ....\..Q.,.@$..Q
02-09 23:16:41.289: I/DEBUG(8990):     5db19c84 00000001 41cfa710 00000000 00000000  .......A........
02-09 23:16:41.289: I/DEBUG(8990):     5db19c94 408f1a55 51878f24 590a6fb9 4032aaa1  U..@$..Q.o.Y..2@
02-09 23:16:41.289: I/DEBUG(8990):     5db19ca4 5d4cbb00 00000000 00000000 40951a6c  ..L]........l..@
02-09 23:16:41.289: I/DEBUG(8990):     5db19cb4 401a6a9c 00020102 5d4cbaf0 ffffbfff  .j.@......L]....
02-09 23:16:41.289: I/DEBUG(8990): memory near ip:
02-09 23:16:41.289: I/DEBUG(8990):     4032aa80 0107f10d 46106883 47982201 bf082801  .....h.F.".G.(..
02-09 23:16:41.289: I/DEBUG(8990):     4032aa90 0007f89d f04fd001 bd0e30ff 0003f4a4  ......O..0......
02-09 23:16:41.289: I/DEBUG(8990):     4032aaa0 b92ab508 44794905 4008e8bd ba56f02e  ..*..IyD...@..V.
02-09 23:16:41.289: I/DEBUG(8990):     4032aab0 68436810 47984610 bf00bd08 0003f474  .hCh.F.G....t...
02-09 23:16:41.289: I/DEBUG(8990):     4032aac0 4ff0e92d 4604b0a5 461e4693 9d2f9f2e  -..O...F.F.F../.
02-09 23:16:41.289: I/DEBUG(8990): memory near sp:
02-09 23:16:41.289: I/DEBUG(8990):     5db19c58 40951578 401a6a9c 5d4cbaf0 00000000  x..@.j.@..L]....
02-09 23:16:41.289: I/DEBUG(8990):     5db19c68 41cfa710 5d4cbaf0 df0027ad 00000000  ...A..L].'......
02-09 23:16:41.289: I/DEBUG(8990):     5db19c78 51878f5c 408c2cf4 51878f24 00000001  \..Q.,.@$..Q....
02-09 23:16:41.289: I/DEBUG(8990):     5db19c88 41cfa710 00000000 00000000 408f1a55  ...A........U..@
02-09 23:16:41.289: I/DEBUG(8990):     5db19c98 51878f24 590a6fb9 4032aaa1 5d4cbb00  $..Q.o.Y..2@..L]
02-09 23:16:41.289: I/DEBUG(8990): code around pc:
02-09 23:16:41.289: I/DEBUG(8990):     00000030 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.289: I/DEBUG(8990):     00000040 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.289: I/DEBUG(8990):     00000050 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.289: I/DEBUG(8990):     00000060 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.289: I/DEBUG(8990):     00000070 ffffffff ffffffff ffffffff ffffffff  ................
02-09 23:16:41.289: I/DEBUG(8990): code around lr:
02-09 23:16:41.289: I/DEBUG(8990):     4032aa98 bd0e30ff 0003f4a4 b92ab508 44794905  .0........*..IyD
02-09 23:16:41.299: I/DEBUG(8990):     4032aaa8 4008e8bd ba56f02e 68436810 47984610  ...@..V..hCh.F.G
02-09 23:16:41.299: I/DEBUG(8990):     4032aab8 bf00bd08 0003f474 4ff0e92d 4604b0a5  ....t...-..O...F
02-09 23:16:41.299: I/DEBUG(8990):     4032aac8 461e4693 9d2f9f2e 49f2b92a f7d54479  .F.F../.*..IyD..
02-09 23:16:41.299: I/DEBUG(8990):     4032aad8 4658ecd6 9930e1d4 49efb929 f7d54479  ..XF..0.)..IyD..

1 个答案:

答案 0 :(得分:0)

您确实需要发布您实际使用的代码(及其日志消息),以及您希望人们能够随时帮助您的情况。

我怀疑在调用googleDisplayAd()时,interstitial属性为null。但是没有看到代码和日志,很难知道。将以下日志添加到googleDisplayAd()。

Log.d(TAG, "interstialAd=" + interstitial);

它是否具有非空值?