Adbanner没有加载

时间:2016-01-06 06:50:33

标签: java android

我已在我的项目中实施了adbanner。但由于某些原因,广告没有加载,我在日志中收到一些错误。

以下是mainactivity.xml

中的代码
 <com.google.android.gms.ads.AdView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/adView"
        ads:adUnitId="AD ID HERE"
        ads:adSize="BANNER"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

Android manifest



  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"/>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


</manifest>

Main.java

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

   // Look up the AdView as a resource and load a request.
        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);

我之前在另一个项目上使用过此代码没有问题。但现在,我只是得到了这些错误。

2460-2504/com.sounds.apps.sounds I/OpenGLRenderer﹕ Initialized EGL, version 1.4
01-05 22:33:19.015    2460-2504/com.sounds.apps.sounds D/﹕ HostConnection::get() New Host Connection established 0x9ec40f30, tid 2504
01-05 22:33:19.126    2460-2504/com.sounds.apps.sounds D/OpenGLRenderer﹕ Enabling debug mode 0
01-05 22:33:19.160    2460-2504/com.sounds.apps.sounds W/EGL_emulation﹕ eglSurfaceAttrib not implemented
01-05 22:33:19.160    2460-2504/com.sounds.apps.sounds W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x9ec7eaa0, error=EGL_SUCCESS
01-05 22:33:20.484    2460-2494/com.sounds.apps.sounds W/chromium﹕ [WARNING:proxy_service.cc(901)] PAC support disabled because there is no system implementation
01-05 22:33:20.491    2460-2460/com.sounds.apps.sounds W/chromium﹕ [WARNING:data_reduction_proxy_settings.cc(403)] SPDY proxy OFF at startup
01-05 22:33:20.512    2460-2460/com.sounds.sapps.sounds W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
01-05 22:33:20.517    2460-2460/com.ounds.sapps.sounds W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring
01-05 22:33:20.757    2460-2460/com.sounds.apps.sounds I/Ads﹕ Ad finished loading.
01-05 22:33:20.789    2460-2504/com.ounds.apps.sounds E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
01-05 22:33:20.790    2460-2504/com.sounds.apps.ounds E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
01-05 22:33:20.838    2460-2504/com.sounds.apps.ounds E/eglCodecCommon﹕ **** ERROR unknown type 0x0 (glSizeof,72)
01-05 22:33:20.848    2460-2504/com.sounds.apps.ounds E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
01-05 22:33:20.858    2460-2504/com.sounds.apps.ounds E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0

glUtilParamsize: unkown param 0x00000bd0也只重复了40行。

我只是弄清楚,为什么adbanner没有显示。

1 个答案:

答案 0 :(得分:0)

我遇到同样的问题,并以编程方式更改添加adView。

    <FrameLayout
            android:id="@+id/frameAds"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >
        </FrameLayout>

FrameLayout parentView = (FrameLayout)findViewById(R.id.frameAds);

您必须在xml中删除Adview。并添加LinearLayout(Framelayout,RelativeLayout ...):

CommandBehavior.CloseConnection