2013-09-29 42 views
1

我已经通过了所有可以找到的示例,但我不确定错误在哪里。我的代码与其他应用程序相同,我只是试图将admob添加到帐户中。这是我可以从我的logcat中抓取的。Android Admob force closin

09-29 13:19:28.026: D/ActivityThread(29906): setTargetHeapUtilization:0.25 
09-29 13:19:28.026: D/ActivityThread(29906): setTargetHeapIdealFree:8388608 
09-29 13:19:28.026: D/ActivityThread(29906): setTargetHeapConcurrentStart:2097152 
09-29 13:19:28.256: D/dalvikvm(29906): GC_FOR_ALLOC freed 55K, 31% free 14739K/21059K, paused 16ms, total 16ms 
09-29 13:19:28.346: D/dalvikvm(29906): GC_CONCURRENT freed <1K, 21% free 24914K/31239K, paused 12ms+22ms, total 45ms 
09-29 13:19:28.586: I/webclipboard(29906): clipservice: [email protected] 
09-29 13:19:28.617: V/webkit(29906): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42d994a8} 
09-29 13:19:28.667: I/webclipboard(29906): clipservice: [email protected] 
09-29 13:19:28.667: V/webkit(29906): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42dc21c8} 
09-29 13:19:28.747: V/webkit(29906): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42e2db50} 
09-29 13:19:28.747: I/webclipboard(29906): clipservice: [email protected] 
09-29 13:19:28.767: I/Ads(29906): To get test ads on this device, call adRequest.addTestDevice("512CF178FE3E3613A01DC3FBA545BD86"); 
09-29 13:19:28.897: W/dalvikvm(29906): threadid=1: thread exiting with uncaught exception (group=0x41480438) 
09-29 13:19:28.897: E/AndroidRuntime(29906): FATAL EXCEPTION: main 
09-29 13:19:28.897: E/AndroidRuntime(29906): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mrj05hua.hanselgretelwhfree/com.mrj05hua.hanselgretelwhfree.MainActivity}: java.lang.IllegalStateException: ScrollView can host only one direct child 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread.access$700(ActivityThread.java:143) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.os.Handler.dispatchMessage(Handler.java:99) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.os.Looper.loop(Looper.java:137) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread.main(ActivityThread.java:4950) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at java.lang.reflect.Method.invokeNative(Native Method) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at java.lang.reflect.Method.invoke(Method.java:511) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at dalvik.system.NativeStart.main(Native Method) 
09-29 13:19:28.897: E/AndroidRuntime(29906): Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.widget.ScrollView.addView(ScrollView.java:316) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.view.LayoutInflater.rInflate(LayoutInflater.java:750) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.Activity.setContentView(Activity.java:1914) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at com.mrj05hua.hanselgretelwhfree.MainActivity.onCreate(MainActivity.java:73) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.Activity.performCreate(Activity.java:5179) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 
09-29 13:19:28.897: E/AndroidRuntime(29906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 
09-29 13:19:28.897: E/AndroidRuntime(29906): ... 11 more 
09-29 13:19:28.957: I/Ads(29906): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"7723615705340179905","seq_num":"1","slotname":"pub-4235852256372242","u_w":640,"msid":"com.mrj05hua.hanselgretelwhfree","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"wi","app_name":"1.android.com.mrj05hua.hanselgretelwhfree","hl":"en","gnt":13,"carrier":"311480","u_audio":1,"kw":[],"u_sd":2,"ms":"IV6O237njvDEvF1ofv78lOtjwh57ebkvua5-rxjoFyAyMTipUBB2050GvmOPvdWNPsxLTPq4F1GRW1dJdqubdcv0uviIrWVHoPHn0rAGzh4DUHlSTfXHBcAiMsW5AXD6hn-AafG2QBHLoY5vkpaWhotmzeAq-VRV5udolUxpqQxMj7rfhI9wXn5T8o5ths5UUcLfHFTR4Hd7cKftCJQkbazmOsQrDCu4UGju2VDmS5pZ5ZNbvQePhv9OKQHcbNpRGbTtbU_DMKCU3xjqWiaON4LmdTWjwTii0ahlDwdIgSvJvOh9TUMUeDD_ac3jAhw64hZUFqNNkeuZk5UeJ2XuvQ","mv":"80230011.com.android.vending","isu":"512CF178FE3E3613A01DC3FBA545BD86","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"u_h":360,"pt":2,"bas_on":0,"ptime":0});</script></head><body></body></html> 
+0

你能发布您的代码的相关部分?日志说,错误可能是在你的文件的第73行MainActivity.java – Eudhan

回答

1

的问题是,在你的布局你有滚动视图下,而不是父布局下的AdMob。 ScrollViews只能托管一个视图,您真正需要的是让主要部分滚动,然后广告像页脚一样保持不变。

此基础上,日志是显而易见的:

Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child 
+1

我注意到,我发布后。我无法投放广告,但我已将其作为全屏应用,并将admob广告作为标题。现在尝试它作为页脚。感谢您的帮助 –

+0

我得到的应用程序运行,仍然无法让任何广告在应用程序中直观发布。它运行没有错误,所以我不知道我要去哪里错了,因为没有广告测试或真实。 –

+1

@ mr.j05hua我需要看代码,我推荐你把它作为一个新问题发布,因为这个关闭 –