android - "Can' t 获取第一个layout后的viewWidth”错误

标签 android xml admob

我一辈子都无法修复这个错误。我查看了 Google 及其周边,但没有任何解决方案奏效。我的广告似乎在 Android 1.5 和 1.6 上运行良好,但在版本 2 以上时我收到了该错误。

我已将我的广告放在 LinearLayout 中,这是 ScrollView 中的第一个布局。

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

    <LinearLayout 
        android:orientation="vertical" 
        android:id="@+id/drillactivity"
        android:layout_width="fill_parent" 
        android:layout_gravity="bottom" 
        android:layout_height="340dp">

             <com.google.ads.AdView
                android:id="@+id/adView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                ads:adUnitId="my id goes here"
                ads:adSize="BANNER"
                ads:loadAdOnCreate="true"/>

我没有在类(class)中为广告使用任何代码。我更喜欢只通过 xml 来完成。

最佳答案

我有类似的黑屏警告。问题是设备上有两个不同的应用程序具有相同的 AdMob ID。

我删除了第二个应用程序(错误地使用了相同的 ID)并且问题消失了。

关于android - "Can' t 获取第一个layout后的viewWidth”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7436279/

相关文章:

c# - Unity RewardAd 函数调用更多次而不仅仅是一次

android - 在 Android Studio 中将 Admob 横幅调整为屏幕大小

android - 音轨发布

android - tableLayout 中的复选框 selectAll\DeselectAll

iphone - WSDL/XML 解析 iOS objective-c

xml - TSQL XML 将节点值转换为 int

javascript - 无法让 Nativescript 插件工作 "nativescript-admob"

java - 如何修复 minSdkVersion 21 中的 DEX 64K 方法限制?

Android:如何在旋转后恢复停止的计时器状态?

javascript - 如何拥有相同的重复 div 结构,但在每个 div 中解析不同的 xml 数据