2014-10-28 138 views
11

我的問題是,根本沒有在我的應用程序,測試模式中顯示廣告。我將繼續針對測試模式提出這個問題,一旦我開始工作,我會擔心實時廣告。Admob廣告服務器沒有填充 - 未能加載廣告:3

發展信息

我使用Eclipse進行開發。

我已經在我的Android應用中使用Google Play服務和Admob設置了廣告,如Google提供的在線文檔中所述。

我已經使用addTestDevice(「xxxxxxxxxxxxxxxx」)添加了我的設備ID,並且檢查了散列設備ID多次以確保它是正確的。

的問題(參見下面的日誌信息)

當我運行我的設備上的應用,沒有廣告顯示在所有。即使將我的設備添加爲測試設備,也會發生這種情況。

我已經搜索了高和低,並出現了很多類似的問題,但我還沒有找到這個具體問題的答案。

logcat的輸出

10-28 13:56:41.659: I/Ads(1704): Starting ad request. 
10-28 13:56:42.187: I/Ads(1704): No fill from ad server. 
10-28 13:56:42.187: W/Ads(1704): Failed to load ad: 3 
10-28 13:56:42.199: W/Ads(1704): No GMSG handler found for GMSG: gmsg://mobileads.google.com/jsLoaded?google.afma.Notify_dt=1414504602197 

我的動態

package bb.hoppingbird; 

    import org.cocos2d.layers.CCScene; 
    import org.cocos2d.nodes.CCDirector; 
    import org.cocos2d.opengl.CCGLSurfaceView; 

    import com.google.android.gms.ads.AdListener; 
    import com.google.android.gms.ads.AdRequest; 
    import com.google.android.gms.ads.AdSize; 
    import com.google.android.gms.ads.AdView; 
    import com.google.android.gms.ads.InterstitialAd; 

    import android.app.Activity; 
    import android.content.SharedPreferences; 
    import android.media.MediaPlayer; 
    import android.os.Bundle; 
    import android.support.v4.view.ViewPager.LayoutParams; 
    import android.util.DisplayMetrics; 
    import android.view.KeyEvent; 
    import android.widget.RelativeLayout; 
    import android.widget.Toast; 

    public class MainActivity extends Activity { 

    private CCGLSurfaceView mGLSurfaceView; 

    //<!-- Admob Ads Using Google Play Services SDK --> 
    private static final String AD_UNIT_ID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxx"; 
    private static final String AD_INTERSTITIAL_UNIT_ID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxx"; 


    /** The Admob ad. */ 
    private InterstitialAd interstitialAd = null; 
    public AdView adView = null; 

    public static MainActivity app; 

    public void onCreate(Bundle savedInstanceState) 
    { 
     app = this; 

     super.onCreate(savedInstanceState); 

     // set view 
     mGLSurfaceView = new CCGLSurfaceView(this); 


     //Ads ---------------- 
     // Create the adView 
     RelativeLayout layout = new RelativeLayout(this); 
     layout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); 

     //<!-- Ads Using Google Play Services SDK --> 
     adView = new AdView(this); 
     adView.setAdSize(AdSize.SMART_BANNER); 
     adView.setAdUnitId(AD_UNIT_ID); 

     // Add the adView to it 
     RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
       LayoutParams.WRAP_CONTENT, 
       LayoutParams.WRAP_CONTENT); 
     params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); 
     params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); 

     adView.setLayoutParams(params); 

     layout.addView(mGLSurfaceView); 
     layout.addView(adView); 

     setContentView(layout); 
     //New AdRequest 
     AdRequest adRequest = new AdRequest.Builder() 
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
     .addTestDevice("0D47C6944503F0284666D16BB79BF684") 
     .build(); 

    // Start loading the ad in the background. 
    adView.loadAd(adRequest); 


     //-----------------------------------------------------Interstitial Add 
     // Create an Interstitial ad. 
     interstitialAd = new InterstitialAd(this); 
     interstitialAd.setAdUnitId(AD_INTERSTITIAL_UNIT_ID); 
     interstitialAd.setAdListener(new AdListener() { 
       @Override 
       public void onAdLoaded() { 
       interstitialAd.show(); 
       } 

       @Override 
       public void onAdFailedToLoad(int errorCode) { 
        Toast.makeText(getApplicationContext(), "Interstitial Ads loading failed", Toast.LENGTH_SHORT).show(); 
       } 
     }); 
     // Load the interstitial ad. 
     //showInterstitialAds(); 

     //---------------------- 
     // set director 
     CCDirector director = CCDirector.sharedDirector(); 
     director.attachInView(mGLSurfaceView); 
     director.setAnimationInterval(1/60); 

     // get display info 
     DisplayMetrics displayMetrics = new DisplayMetrics(); 
     getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); 
     G.display_w = displayMetrics.widthPixels; 
     G.display_h = displayMetrics.heightPixels; 
     G.scale = Math.max(G.display_w/1280.0f, G.display_h/800.0f); 
     G.width = G.display_w/G.scale; 
     G.height = G.display_h/G.scale; 

     // get data 
     SharedPreferences sp = CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0); 
     G.music = sp.getBoolean("music", true); 
     G.sound = sp.getBoolean("sound", true); 

     // create sound 
     G.soundMenu = MediaPlayer.create(this, R.raw.menu); 
     G.soundMenu.setLooping(true); 
     G.soundGame = MediaPlayer.create(this, R.raw.game); 
     G.soundGame.setLooping(true); 
     G.soundCollide = MediaPlayer.create(this, R.raw.collide); 
     G.soundJump = MediaPlayer.create(this, R.raw.jump); 
     G.soundLongJump = MediaPlayer.create(this, R.raw.long_jump); 
     G.soundSpeedDown = MediaPlayer.create(this, R.raw.speed_down); 
     G.soundSpeedUp = MediaPlayer.create(this, R.raw.speed_up); 
     G.soundDirection = MediaPlayer.create(this, R.raw.direction_sign); 
     G.soundClick = MediaPlayer.create(this, R.raw.menu_click); 
     G.soundCollect = MediaPlayer.create(this, R.raw.collect); 
     G.bgSound = G.soundMenu; 

     // show menu 
     CCScene scene = CCScene.node(); 
     scene.addChild(new MenuLayer(true)); 
     director.runWithScene(scene); 
    } 

    @Override 
    public void onPause() 
    { 
     if (adView != null) { 
       adView.pause(); 
      } 

     super.onPause(); 
     G.bgSound.pause(); 
     CCDirector.sharedDirector().onPause(); 
    } 

    @Override 
    public void onResume() 
    { 
     super.onResume(); 

     if (adView != null) { 
      adView.resume(); 
      } 

     if(G.music) G.bgSound.start(); 

     CCDirector.sharedDirector().onResume(); 
    } 

    @Override 
    public void onDestroy() 
    { 
     // Destroy the AdView. 
     if (adView != null) { 
      adView.destroy(); 
     } 

     super.onDestroy(); 
     G.bgSound.pause(); 
     CCDirector.sharedDirector().end(); 
    } 

    @Override 
    public boolean onKeyDown(int keyCode, KeyEvent event) 
    { 
     if(keyCode == KeyEvent.KEYCODE_BACK) 
     { 
      CCDirector.sharedDirector().onKeyDown(event); 
      return true; 
     } 
     return super.onKeyDown(keyCode, event); 
    } 

    public void showInterstitialAds() 
    { 
     runOnUiThread(new Runnable() { 
      public void run() { 
       AdRequest interstitialAdRequest = new AdRequest.Builder().build(); 
       interstitialAd.loadAd(interstitialAdRequest); 
      } 
     }); 
    } 
} 
+2

您不應在網絡上明顯發佈 AD_UNIT_ID和AD_INTERSTITIAL_UNIT_ID – 2014-10-28 14:28:24

+0

您是否確定橫幅廣告或插頁式廣告是否失敗?或者兩者兼得?你還使用谷歌在他們的教程中提供的測試AD_UNIT_ID? – 2014-10-28 14:49:33

+0

嗨@TimCastelijns橫幅和interstital失敗。謝謝 – 2014-10-28 14:54:08

回答

6

的問題來,只有當該特定應用從Play商店中暫停。也許你可以嘗試更改軟件包名稱,也可以使用新的Admob Id。由於遵守規定,特定admob id也有可能被暫停。

+0

我同意這個答案,只需重命名你的包,它將工作100%。 – 2015-01-30 09:37:46

+1

我今天剛遇到這個。我的應用程序被暫停。更改應用程序名稱 - ' TestApp' – mboy 2015-03-05 01:48:17

+1

這是錯誤的。原因可能是應用程序被暫停,但還有其他可能的原因。例如,在admob界面中創建另一個應用程序單元可能會有所幫助。 – Damnum 2015-07-19 19:42:43

0

我也有這個問題。直到我去Admob.com和「手動」添加我的應用程序,所以我可以得到我的「廣告單元ID」。我將此廣告單元ID字符串作爲參數my adView.setAdUnitId調用。然後,我安裝並打開了通過Eclipse生成的「發佈」APK。文件>導出>導出Android應用程序

6

如果您創建adunit並立即使用它可能會顯示此錯誤,請嘗試在30分鐘或更長時間後加載廣告。

0

我今天也有這個問題。我的應用程序未被暫停,但apk名稱更改無效。我們已經更名爲測試應用程序以將其發佈到生產中;我們更改了apk名稱。這使我們的廣告填充MoPub和Admob。

0

從Admob服務器禁用廣告,您的代碼無問題,請嘗試更改包名稱,然後查看是否顯示廣告。然後聯繫admob查看問題。

1

如果您的AdMob帳戶僅針對橫幅廣告進行配置,並且您使用的是插頁式廣告,則可能會出現此問題。我的2美分。

1

如果您的應用支持Designed for Families。

Bundle extras = new Bundle(); 
extras.putBoolean("is_designed_for_families", true); 

AdRequest request = new AdRequest.Builder() 
     .addNetworkExtrasBundle(AdMobAdapter.class, extras) 
     .build(); 
+0

它沒有幫助。出現相同的錯誤。 – 2016-09-13 08:04:14

+0

同樣的錯誤沒有。幫助完整。 – 2017-11-26 04:28:46

0

在我的情況,這是錯誤的,要求從其他未支持該廣告的區域的地理限制廣告的效果。如果我將廣告請求包的位置硬編碼在可接受區域內,或者根本不包含請求中的位置,則廣告呈現得很好;否則我在控制檯中出現與OP相同的錯誤。

0

我在Galaxy S4上測試,後來我的朋友在Note 2上測試過,它沒有顯示橫幅廣告。因此問題是測試設備ID。如果您正在測試,請確保測試設備ID是您正在測試的設備。

0

需要使用ID,谷歌爲當前的測試設備爲您提供。你可以找到它在logcat中,只要找到這樣的事情:

Ads: Use AdRequest.Builder.addTestDevice("903A70A3D439E256BAED43E65A79928E") to get test ads on this device. 
0

在我的情況,我的橫幅廣告高空氣污染,特別是與寬屏幕(我已經使用智能橫幅尺寸)某些設備具有響應碼3,將依賴從com.google.android.gms.ads更改爲com.google.firebase:firebase-ads(如果您使用的是Firebase)解決了我的問題。