【问题标题】:App force closes on adding admob webview应用强制在添加 admob webview 时关闭
【发布时间】:2011-06-22 09:21:37
【问题描述】:

我的应用中有一个 webview,就是这样。我对其进行了测试,它可以正常工作,但是当我将 admob 添加到代码中时,它开始强制关闭。我做了一些评论,看看是什么导致它关闭,当我从 main.xml 中删除与 Abmob 相关的代码时,它开始正常工作。

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >


<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="800dp" />

 <com.admob.android.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="a14d--mypub--id--"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true"/>  />

</RelativeLayout>

谁能告诉我我做错了什么?

【问题讨论】:

标签: android crash webview admob


【解决方案1】:

您无需通过 Web 视图来显示 Admob。 只需从您的 xml 文件中删除 web iew,然后运行您的应用程序,它就会工作。否则在单独的布局标签中提供 Admob 代码。

<com.admob.android.ads.AdView 
xmlns:ads="http://schemas.android.com/apk/res/**Prove Your Package name,e.g. com.xyz.abc**"
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="a14d--mypub--id--"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true"/>

【讨论】:

  • 实际上我正在使用 webview 来做其他事情(那是我的应用程序)
  • LOGCAT E/AndroidRuntime(25559): java.lang.RuntimeException: 无法启动活动组件信息{com.arv.mediafire/com.arv.mediafire.MediafireActivity}: android.view .InflateException:二进制 XML 文件第 12 行:膨胀类 com.admob.and roid.ads.AdView 时出错
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-29
  • 1970-01-01
  • 2012-02-01
相关资源
最近更新 更多