当我在模拟器中运行应用程序时,它运行良好,显示启动画面但没有打开带有广告横幅的屏幕。当我删除活动中添加的广告横幅代码时,它会打开。代码是
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="**********"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
注意:我正在使用 Adroid 2.2 和 API-8 如何更改它们
当我添加此代码时,出现以下错误
04-03 13:10:44.518: W/dalvikvm(374): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-03 13:10:44.567: E/AndroidRuntime(374): FATAL EXCEPTION: main
04-03 13:10:44.567: E/AndroidRuntime(374): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rms.remotedesktop1/com.rms.remotedesktop1.Home}: android.view.InflateException: Binary XML file line #30: Error inflating class com.google.ads.AdView
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.os.Looper.loop(Looper.java:123)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-03 13:10:44.567: E/AndroidRuntime(374): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 13:10:44.567: E/AndroidRuntime(374): at java.lang.reflect.Method.invoke(Method.java:521)
04-03 13:10:44.567: E/AndroidRuntime(374): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-03 13:10:44.567: E/AndroidRuntime(374): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-03 13:10:44.567: E/AndroidRuntime(374): at dalvik.system.NativeStart.main(Native Method)
04-03 13:10:44.567: E/AndroidRuntime(374): Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.google.ads.AdView
04-03 13:10:44.567: E/AndroidRuntime(374): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-03 13:10:44.567: E/AndroidRuntime(374): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.Activity.setContentView(Activity.java:1647)
04-03 13:10:44.567: E/AndroidRuntime(374): at com.rms.remotedesktop1.Home.onCreate(Home.java:27)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-03 13:10:44.567: E/AndroidRuntime(374): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-03 13:10:44.567: E/AndroidRuntime(374): ... 11 more
提前致谢