我一辈子都无法修复这个错误。我查看了 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/