【问题标题】:Android Admob Banners don't showAndroid Admob 横幅不显示
【发布时间】:2015-01-18 11:11:36
【问题描述】:

我有一个问题:

我将 Eclipse 与 ADT 结合使用,但横幅未显示在 Google Ads 示例应用程序中,我不知道为什么。

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gms.samples.ads"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="18" />

    <!-- Used to request banner and interstitial ads. -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Used to avoid sending an ad request if there is no connectivity. -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <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="com.google.android.gms.samples.ads.GoogleAdsSampleActivity"
            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=".BannerXmlActivity"
            android:label="@string/banner_in_xml"/>
        <activity android:name=".BannerCodeActivity"
            android:label="@string/banner_in_code"/>
        <activity android:name=".InterstitialActivity"
            android:label="@string/interstitial"/>
        <!-- Activity required to show ad overlays. -->
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>

</manifest>

代码

setContentView(R.layout.activity_banner_code_ad_listener);

        mAdView = new AdView(this);
        mAdView.setAdUnitId("ca-app-pub-8xxxxxxxxxxxxxxx/4xxxxxxxxx");
        mAdView.setAdSize(AdSize.BANNER);

        final RelativeLayout layout = (RelativeLayout) findViewById(R.id.mainLayout);
        layout.addView(mAdView);

        mAdView.setAdListener(new ToastAdListener(this));
        AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice("AAxAxxxAxAxxxAxxxAxxxAAxxAxxxAA")
        .build();
        mAdView.loadAd(adRequest);

项目属性:

target=android-18
android.library.reference.1=../google-play-services_lib

在 LogCat 中:

Google Play services out of date.  Requires 6587000 but found 5089030

GooglePlayServices not available due to error 2

VFY: unable to resolve virtual method 8193: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V

JS: The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html displayed insecure content from file:///android_asset/webkit/android-weberror.png.

The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html displayed insecure content from file:///android_asset/webkit/android-weberror.png.

JS: Uncaught ReferenceError: AFMA_buildAdURL is not defined (null:1)

Uncaught ReferenceError: AFMA_buildAdURL is not defined at null:1

应用程序工作,但没有横幅。对于监听器,我发现我有一个内部错误。

互联网工作,我在项目中包含了 google-play-services_lib rev 22。

我在另一部手机上试过,但结果一样。

【问题讨论】:

    标签: android admob banner


    【解决方案1】:

    始终使用最新的目标构建您的项目:

    android:targetSdkVersion="21"
    

    还可以尝试通过 SDK 管理器更新您的 Google Play 服务 (GMS)。

    【讨论】:

    • 我更改了 project-property: target=android-21 和 manifest: android:targetSdkVersion="21" 但同样的事情。在 SDK Manager 中,Google play services 没有更多更新,rev 为 22,我没有找到 Google Play Services (GMS)。
    【解决方案2】:

    您设备上的 Google Play 服务版本已过期。

    在您的设备上,访问 Google Play 并查找更新。

    【讨论】:

    • 在 Google 商店中,当我搜索 Google Play 服务时,它不显示。
    【解决方案3】:

    添加到您的清单
    但将您的 APPLICATION_ID 指向第二行

    <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-11111111111111~222222222"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      相关资源
      最近更新 更多