1

我正在嘗試將InterstitialAd添加到我的項目中。我已經添加了必要的庫Android - InterstitialAd - 未找到Google Play服務資源

  1. 從SDK經理

  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. 

它看起來像廣告加載很好,但沒有顯示在屏幕上。 我沒有使用任何其他谷歌API(因爲我已閱讀所有有關此主題和人們總是有問題時,同時使用adMob和任何其他谷歌API)

你有一個關於如何解決它的想法?

+0

我有同樣的問題,也許我應該叫displayInterstitial()後錯過了一些配置步... – Paolo

+0

。現在,您在onCreate中調用它,並且可能不會加載完成。嘗試在按鈕onclick處理程序或其他東西中調用它。 –

回答

0

快速搜索似乎也印證了這

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共同日誌emssage。但它似乎沒有影響。即它是良性的。

+0

問題是廣告根本沒有顯示。 – user3119384

+0

威廉是對的。來自https://developers.google.com/mobile-ads-sdk/kb/#resourcesnotfound –

0

我也許回答遲了一點,但我想原因可能只是您的廣告在展示前沒有時間加載。

在您的代碼中,您希望在加載廣告後立即顯示廣告,但它沒有留下足夠的時間。

您應該稍後將代碼中的呼叫displayInterstitial();

1

轉到admob頁面並創建新的插頁式廣告(MY_AD_UNIT_ID)。不要使用舊的Banner 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(); 
     } 
     } 
+0

的同樣的答案這是什麼解決了我的問題,我爲我的插頁式廣告使用了禁止的廣告ID ..非常感謝,多年來一直困在這一個。 – Tssomas

相關問題