【问题标题】:Android - InterstitialAd - The Google Play services resources were not foundAndroid - InterstitialAd - 未找到 Google Play 服务资源
【发布时间】:2014-01-08 06:43:12
【问题描述】:

我正在尝试将 InterstitialAd 添加到我的项目中。我已经添加了必要的库

  1. 从 sdk manager 下载 google 服务

  2. 将项目导入为android代码

  3. 将其添加到属性>库中

这是我的代码:

 import com.google.android.gms.ads.*;

 public class MainActivity extends FragmentActivity implements
        ActionBar.TabListener {

    ...
    private InterstitialAd interstitial;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ...

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("a152caa4c3be05b");

        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Begin loading your interstitial.
        interstitial.loadAd(adRequest);

        ...

        displayInterstitial();
    }

    ...

    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
          interstitial.show();
        }
      }

 }

这是logcat

 01-08 08:30:00.615: D/dalvikvm(669): DexOpt: --- BEGIN 'ads-1769811527.jar' (bootstrap=0) ---
 01-08 08:30:00.705: D/dalvikvm(669): DexOpt: --- END 'ads-1769811527.jar' (success) ---
 01-08 08:30:00.705: D/dalvikvm(669): DEX prep '/data/data/info.androidhive.tabsswipe/cache/ads-1769811527.jar': unzip in 0ms, rewrite 88ms
 01-08 08:30:00.745: I/Ads(669): Use AdRequest.Builder.addTestDevice("5CEAF7E172F8B76E72193FA048D8DCB1") to get test ads on this device.
 01-08 08:30:00.755: I/Ads(669): Starting ad request.
 01-08 08:30:00.945: W/ResourceType(669): getEntry failing because entryIndex 13 is beyond type entryCount 1
 01-08 08:30:00.945: W/ResourceType(669): Failure getting entry for 0x7f0b000d (t=10 e=13) in package 0 (error -2147483647)
 01-08 08:30:00.945: E/GooglePlayServicesUtil(669): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
 01-08 08:30:01.275: W/ResourceType(669): getEntry failing because entryIndex 13 is beyond type entryCount 1
 01-08 08:30:01.275: W/ResourceType(669): Failure getting entry for 0x7f0b000d (t=10 e=13) in package 0 (error -2147483647)
 01-08 08:30:01.275: E/GooglePlayServicesUtil(669): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
 01-08 08:30:01.280: W/ResourceType(669): getEntry failing because entryIndex 13 is beyond type entryCount 1
 01-08 08:30:01.280: W/ResourceType(669): Failure getting entry for 0x7f0b000d (t=10 e=13) in package 0 (error -2147483647)
 01-08 08:30:01.280: E/GooglePlayServicesUtil(669): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
 01-08 08:30:01.505: W/InputMethodManager(669): Ignoring onBind: cur seq=1831, given seq=1830
 01-08 08:30:01.505: W/IInputConnectionWrapper(669): getTextBeforeCursor on inactive InputConnection
 01-08 08:30:01.565: W/IInputConnectionWrapper(669): getTextAfterCursor on inactive InputConnection
 01-08 08:30:01.565: W/IInputConnectionWrapper(669): finishComposingText on inactive InputConnection
 01-08 08:30:01.620: W/IInputConnectionWrapper(669): finishComposingText on inactive InputConnection
 01-08 08:30:02.625: I/Ads(669): Ad finished loading.

看起来广告加载良好,但屏幕上没有显示任何内容。 我没有使用任何其他 google api(因为我已经阅读了所有关于此的主题,并且人们在使用 adMob 和任何其他 google api 时总是遇到问题)

您知道如何解决它吗?

【问题讨论】:

  • 我也有同样的问题,可能是我错过了一些配置步骤...
  • 您应该稍后调用 displayInterstitial()。现在,您在 onCreate 中调用它,它可能没有加载完成。尝试在按钮 onclick 处理程序或其他东西中调用它。

标签: android google-play admob google-play-services interstitial


【解决方案1】:

转到 admob 页面并创建新的插页式广告 (MY_AD_UNIT_ID)。不要使用旧的横幅 ID。

也许这对你有帮助:https://support.google.com/admob/v2/answer/3052638?hl=en

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.player);         
  // Create the interstitial.
            interstitial = new InterstitialAd(this);
            interstitial.setAdUnitId(MY_AD_UNIT_ID);

            // Create ad request.
            AdRequest adRequest = new AdRequest.Builder().build();
            interstitial.setAdListener(new AdListener() {
                 @Override
                 public void onAdLoaded() {
                     displayInterstitial();
                 }
                 @Override
                 public void onAdClosed() {
                 }
             });
            // Begin loading your interstitial.
            interstitial.loadAd(adRequest);
      }
     // Invoke displayInterstitial() when you are ready to display an interstitial.
      public void displayInterstitial() {
        if (interstitial.isLoaded()) {
          interstitial.show();
        }
      }

【讨论】:

  • 这解决了我的问题,我在插页式广告中使用了一个禁止的广告 ID。非常感谢,被这个卡住了好久了。
【解决方案2】:

快速搜索似乎证实了这一点

01-08 08:30:00.945: E/GooglePlayServicesUtil(669): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

是 GPS 的常见日志消息。但是好像没有什么影响。即它是良性的。

【讨论】:

【解决方案3】:

我可能回答的有点晚,但我想原因可能只是您的广告在展示之前没有时间加载。

在您的代码中,您想在加载后立即显示广告,但没有留下足够的时间。

您应该稍后在代码中调用displayInterstitial();。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多