Android 没有足够的空间显示广告。需要411x49 dp,有411x49 dp

Android 没有足够的空间显示广告。需要411x49 dp,有411x49 dp,android,admob,android-linearlayout,Android,Admob,Android Linearlayout,为了让我的广告显示在我的游戏视图下面,我挣扎于布局的顺序。我发现AdView线性布局的布局权重越高,其高度越小。相反,游戏视图线性布局上的较大布局重量降低了其高度 现在我有了足够的空间,但admob仍然在Logcat中抛出一个错误 W/Ads: Not enough space to show ad. Needs 411x49 dp, but only has 411x49 dp. @Override protected void onCreate(Bundle savedInstanceS

为了让我的广告显示在我的游戏视图下面,我挣扎于布局的顺序。我发现AdView线性布局的布局权重越高,其高度越小。相反,游戏视图线性布局上的较大布局重量降低了其高度

现在我有了足够的空间,但admob仍然在Logcat中抛出一个错误

 W/Ads: Not enough space to show ad. Needs 411x49 dp, but only has 411x49 dp.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MobileAds.initialize(this, " xx");

    mAdView = findViewById(R.id.adView);
    AdRequest.Builder b = new AdRequest.Builder();
    b.addTestDevice((AdRequest.DEVICE_ID_EMULATOR));
    b.addTestDevice("xx");
    AdRequest adRequest = b.build();
    mAdView.loadAd(adRequest);
    initialiseView();
}

private void initialiseView() {
    LinearLayout mLinearLayout = findViewById(R.id.linearLayout);

    mGameView = new GameView(this);
    mLinearLayout.addView(mGameView, 0);
}



请尝试将SMART_BANNER替换为BANNER only?您解决了问题吗?是的,已更新到最新的SDK
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <LinearLayout
        android:layout_weight="512"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/linearLayout">
    </LinearLayout>


    <RelativeLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="ca-app-pub-xx">
        </com.google.android.gms.ads.AdView>
    </RelativeLayout>




</LinearLayout>