【问题标题】:Android Admob internal errorAndroid Admob 内部错误
【发布时间】:2015-01-25 08:27:30
【问题描述】:

我将 Eclipse 与 ADT 结合使用,我尝试在 Google Ads 示例中使用 Google Play 服务显示 admob 横幅,但它显示“内部错误”。

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

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

LogCat:

01-25 09:19:01.795: W/GooglePlayServicesUtil(14429): Google Play services out of date.  Requires 6587000 but found 5089030
01-25 09:19:01.845: D/dalvikvm(14429): GC_CONCURRENT freed 864K, 18% free 4349K/5248K, paused 4ms+3ms, total 39ms
01-25 09:19:01.865: W/GooglePlayServicesUtil(14429): Google Play services out of date.  Requires 6587000 but found 5089030
01-25 09:19:01.885: I/Ads(14429): Starting ad request.
01-25 09:19:01.936: I/Ads(14429): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 11
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 12
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 13
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 14
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 15
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 16
01-25 09:19:02.105: I/dalvikvm(14429): Total arena pages for JIT: 17
01-25 09:19:02.265: I/dalvikvm(14429): Total arena pages for JIT: 18
01-25 09:19:02.915: D/dalvikvm(14429): DexOpt: --- BEGIN 'ads-1030805842.jar' (bootstrap=0) ---
01-25 09:19:03.046: D/dalvikvm(14429): DexOpt: --- END 'ads-1030805842.jar' (success) ---
01-25 09:19:03.046: D/dalvikvm(14429): DEX prep '/data/data/com.google.android.gms.samples.ads/cache/ads-1030805842.jar': unzip in 1ms, rewrite 137ms
01-25 09:19:03.115: W/GooglePlayServicesUtil(14429): Google Play services out of date.  Requires 6587000 but found 5089030
01-25 09:19:03.115: E/GooglePlayServicesUtil(14429): GooglePlayServices not available due to error 2
01-25 09:19:03.315: I/dalvikvm(14429): Could not find method android.webkit.WebView.evaluateJavascript, referenced from method com.google.android.gms.internal.gu.evaluateJavascript
01-25 09:19:03.315: W/dalvikvm(14429): VFY: unable to resolve virtual method 8193: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V
01-25 09:19:03.315: D/dalvikvm(14429): VFY: replacing opcode 0x6f at 0x0016
01-25 09:19:04.175: W/Ads(14429): 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.
01-25 09:19:04.175: W/Ads(14429):  (null:1)
01-25 09:19:04.175: W/Web Console(14429): 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.
01-25 09:19:04.175: W/Web Console(14429):  at null:1
01-25 09:19:04.526: E/Ads(14429): JS: Uncaught ReferenceError: AFMA_buildAdURL is not defined (null:1)
01-25 09:19:04.526: E/Web Console(14429): Uncaught ReferenceError: AFMA_buildAdURL is not defined at null:1
01-25 09:19:13.316: D/webviewglue(14429): nativeDestroy view: 0x2a377dc8
01-25 09:19:13.335: W/Ads(14429): There was a problem getting an ad response. ErrorCode: 0
01-25 09:19:13.345: D/dalvikvm(14429): GC_CONCURRENT freed 519K, 17% free 4405K/5248K, paused 5ms+5ms, total 36ms
01-25 09:19:13.375: W/Ads(14429): Failed to load ad: 0

清单:

<?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="21" />

    <!-- 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" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <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>

项目属性:

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

Java 代码:

        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);

如果我必须在手机上更新 Google Play 服务,我不知道该怎么做,因为 Google Play 商店不显示 Google Play 服务。

【问题讨论】:

  • 您是否尝试更新手机上的 Google Play 服务?
  • 如果上述问题的答案是肯定的,请尝试创建一个新的模拟器,并将项目的构建目标设置为 Google API(x86 系统映像)。
  • android:minSdkVersion="15" 改为设置 9
  • 我不知道如何更新手机上的 Google Play 服务。
  • 您正在测试的设备的安卓版本是什么?

标签: android admob google-play-services banner


【解决方案1】:
  1. 检查您是否导入了广告库
  2. 检查您是否在 ADMob 帐户中制作了内部广告
  3. 检查您的手机上是否有 API 9 或更高版本(如果您有 API 8 或更低版本,它将无法工作,因为 API 8 不再支持 Google Play 服务)

然后试试这段代码:

Toast toast = new Toast(this);
toast.setView(ads);
toast.show();

你需要在你的主要活动中调用 toast.show 否则它将不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多