重复启动应用程序时,AdMob会崩溃模拟器

时间:2011-07-05 09:01:44

标签: android debugging admob ads

我正在尝试调试其中包含广告的应用,并且模拟器正在崩溃我。当我试图测试我的代码时,我必须手动将其设置为测试模式似乎很愚蠢。有没有办法防止这种情况发生,如果它处于模拟器模式并且将adRequest设置为测试模式,则会检测到perhapse?有没有其他人能够克服这个或经历过它?我至少无法在手机上重现这个问题。

当我使用Android模拟器时,以下是我认为会导致问题的代码部分:

AdView adView = new AdView(this, AdSize.BANNER, "xxxxxx");
LinearLayout layout = (LinearLayout) this.findViewById(R.id.adview_layout);
layout.addView(adView);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);

这是来自LogCat的日志:

07-05 10:45:10.627: INFO/ActivityManager(70): Starting activity: Intent { dat=content://com.simpleclock.widget/appwidgets/1 cmp=hobodroid.clock.widget/.Settings (has extras) }
07-05 10:45:10.627: WARN/ActivityManager(70): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { dat=content://com.simpleclock.widget/appwidgets/1 cmp=hobodroid.clock.widget/.Settings (has extras) }
07-05 10:45:10.977: INFO/Ads(3527): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
07-05 10:45:11.037: INFO/Ads(3527): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"hobodroid.clock.widget","simulator":1,"hl":"en","preqs":1,"u_so":"p","slotname":"a14e0eda6eb26ea","js":"afma-sdk-a-v4.1.0","app_name":"8.android.hobodroid.clock.widget","isu":"B3EEABB8EE11C2BE770B684D95219ECB","u_audio":4,"u_w":320,"cap":"m,a","format":"320x50_mb","u_sd":1.5,"net":"ed","u_h":533});</script></head><body></body></html>
07-05 10:45:11.307: INFO/ActivityManager(70): Displayed activity hobodroid.clock.widget/.Settings: 662 ms (total 662 ms)
07-05 10:45:11.947: INFO/Ads(3527): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?msid=hobodroid.clock.widget&hl=en&preqs=1&u_so=p&slotname=a14e0eda6eb26ea&js=afma-sdk-a-v4.1.0&app_name=8.android.hobodroid.clock.widget&isu=B3EEABB8EE11C2BE770B684D95219ECB&u_audio=4&u_w=320&cap=m%2Ca&format=320x50_mb&u_sd=1.5&net=ed&u_h=533&output=html&region=mobile_app&u_tz=-120&ex=1&client_sdk=1&askip=1", "afmaNotifyDt": "null">
07-05 10:45:12.427: INFO/Ads(3527): onReceiveAd()
07-05 10:45:13.217: WARN/KeyCharacterMap(3527): No keyboard for id 0
07-05 10:45:13.217: WARN/KeyCharacterMap(3527): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
07-05 10:45:14.307: INFO/DEBUG(27): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-05 10:45:14.317: INFO/DEBUG(27): Build fingerprint: 'generic/sdk/generic/:1.6/Donut/20842:eng/test-keys'
07-05 10:45:14.317: INFO/DEBUG(27): pid: 3527, tid: 3537  >>> hobodroid.clock.widget <<<
07-05 10:45:14.317: INFO/DEBUG(27): signal 11 (SIGSEGV), fault addr 00000000
07-05 10:45:14.317: INFO/DEBUG(27):  r0 00000007  r1 411b9a50  r2 411b9a50  r3 00000000
07-05 10:45:14.317: INFO/DEBUG(27):  r4 411b9a50  r5 00280df0  r6 00000000  r7 44cc8cac
07-05 10:45:14.317: INFO/DEBUG(27):  r8 44cc8da0  r9 424c2e48  10 424c2e34  fp 00000001
07-05 10:45:14.317: INFO/DEBUG(27):  ip ad083e5c  sp 44cc8c48  lr ad047361  pc ad03fc86  cpsr 00000030
07-05 10:45:14.487: INFO/DEBUG(27):          #00  pc 0003fc86  /system/lib/libdvm.so
07-05 10:45:14.498: INFO/DEBUG(27):          #01  pc 0002f480  /system/lib/libdvm.so
07-05 10:45:14.498: INFO/DEBUG(27):          #02  pc 001f3c52  /system/lib/libwebcore.so
07-05 10:45:14.498: INFO/DEBUG(27):          #03  pc 00260b62  /system/lib/libwebcore.so
07-05 10:45:14.498: INFO/DEBUG(27):          #04  pc 000dac80  /system/lib/libwebcore.so
07-05 10:45:14.498: INFO/DEBUG(27):          #05  pc 000ecc6c  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #06  pc 000df90c  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #07  pc 00188640  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #08  pc 001887bc  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #09  pc 001887e8  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #10  pc 00258ab6  /system/lib/libwebcore.so
07-05 10:45:14.507: INFO/DEBUG(27):          #11  pc 0000e434  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #12  pc 00040b0e  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #13  pc 00013198  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #14  pc 00017be4  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #15  pc 0001762c  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #16  pc 0005282c  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #17  pc 0005284a  /system/lib/libdvm.so
07-05 10:45:14.517: INFO/DEBUG(27):          #18  pc 00047800  /system/lib/libdvm.so
07-05 10:45:14.527: INFO/DEBUG(27):          #19  pc 0000f940  /system/lib/libc.so
07-05 10:45:14.527: INFO/DEBUG(27):          #20  pc 0000f4b4  /system/lib/libc.so
07-05 10:45:14.527: INFO/DEBUG(27): stack:
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c08  44cc8c40  
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c0c  00280df0  [heap]
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c10  4182712a  /data/dalvik-cache/system@framework@core.jar@classes.dex
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c14  4182712b  /data/dalvik-cache/system@framework@core.jar@classes.dex
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c18  00280df0  [heap]
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c1c  00000001  
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c20  00000007  
07-05 10:45:14.527: INFO/DEBUG(27):     44cc8c24  4106ffe0  /dev/ashmem/dalvik-LinearAlloc (deleted)
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c28  00280df0  [heap]
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c2c  00000001  
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c30  00000007  
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c34  ad047361  /system/lib/libdvm.so
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c38  411b9a50  /dev/ashmem/dalvik-LinearAlloc (deleted)
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c3c  00280df0  [heap]
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c40  df002777  
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c44  e3a070ad  
07-05 10:45:14.537: INFO/DEBUG(27): #00 44cc8c48  002cf510  [heap]
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c4c  ad06c894  /system/lib/libdvm.so
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c50  ad03ff19  /system/lib/libdvm.so
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c54  ad06c608  /system/lib/libdvm.so
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c58  439ab0d8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
07-05 10:45:14.537: INFO/DEBUG(27):     44cc8c5c  ad06c608  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c60  ad03fc71  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c64  00297fb8  [heap]
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c68  00000000  
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c6c  ad02f483  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27): #01 44cc8c70  ad06c608  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c74  ad02ff11  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c78  44cc8cac  
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c7c  411b9a50  /dev/ashmem/dalvik-LinearAlloc (deleted)
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c80  aa3dc5d0  /system/lib/libwebcore.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c84  ad02f409  /system/lib/libdvm.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c88  aa1f3c3d  /system/lib/libwebcore.so
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c8c  00297fb8  [heap]
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c90  00000000  
07-05 10:45:14.547: INFO/DEBUG(27):     44cc8c94  aa1f3c55  /system/lib/libwebcore.so
07-05 10:45:15.077: INFO/ActivityManager(70): Starting activity: Intent { dat=content://com.simpleclock.widget/appwidgets/1 cmp=hobodroid.clock.widget/.Settings (has extras) }
07-05 10:45:15.077: WARN/ActivityManager(70): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { dat=content://com.simpleclock.widget/appwidgets/1 cmp=hobodroid.clock.widget/.Settings (has extras) }
07-05 10:45:15.577: INFO/Ads(3527): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
07-05 10:45:15.637: INFO/Ads(3527): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"hobodroid.clock.widget","simulator":1,"hl":"en","preqs":2,"u_so":"p","slotname":"a14e0eda6eb26ea","js":"afma-sdk-a-v4.1.0","app_name":"8.android.hobodroid.clock.widget","isu":"B3EEABB8EE11C2BE770B684D95219ECB","u_audio":4,"u_w":320,"cap":"m,a","format":"320x50_mb","u_sd":1.5,"net":"ed","u_h":533});</script></head><body></body></html>
07-05 10:45:15.877: INFO/ActivityManager(70): Displayed activity hobodroid.clock.widget/.Settings: 796 ms (total 796 ms)
07-05 10:45:16.887: INFO/ActivityManager(70): Process hobodroid.clock.widget (pid 3527) has died.
07-05 10:45:16.887: WARN/ActivityManager(70): Scheduling restart of crashed service hobodroid.clock.widget/.ClockService in 5000ms
07-05 10:45:16.897: INFO/WindowManager(70): WIN DEATH: Window{43856840 hobodroid.clock.widget/hobodroid.clock.widget.Settings paused=false}
07-05 10:45:16.937: WARN/UsageStats(70): Unexpected resume of com.android.launcher while already resumed in hobodroid.clock.widget
07-05 10:45:16.987: ERROR/ActivityThread(70): Failed to find provider info for android.server.checkin
07-05 10:45:16.987: WARN/Checkin(70): Can't log event SYSTEM_SERVICE_LOOPING: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/events
07-05 10:45:16.997: WARN/InputManagerService(70): Got RemoteException sending setActive(false) notification to pid 3527 uid 10024

1 个答案:

答案 0 :(得分:0)

此处讨论了此问题https://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/f72ed8694a28cc7d/ced66f77ddb1e3ad和此处http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/eeb307a33a69765d。建议的解决方法是在Activity.onDestroy()中调用adView.destroy()。似乎有所帮助。

@Override
protected void onDestroy() {
    super.onDestroy();

    //workaround for AdMob crash on 1.6
    AdView adView=(AdView)findViewById(R.id.adView);
    if(adView!=null)
        adView.destroy();
}