Java Admob 没有来自广告服务器的填充 - 无法加载广告:3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26610383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 02:55:38  来源:igfitidea点击:

Admob No fill from ad server - failed to load ad: 3

javaandroideclipseadmobcocos2d-android

提问by Vhycko Mayaut

My issue is that ads are not being displayed at all in my app, test mode or not. I am going to keep this question specific to test mode, and once I get that working I will worry about live ads.

我的问题是我的应用程序中根本没有显示广告,测试模式与否。我将把这个问题特定于测试模式,一旦我开始工作,我就会担心实时广告。

Development Information

发展信息

I am using Eclipse for development.

我正在使用 Eclipse 进行开发。

I have setup ads using Google Play Services and Admob in my Android app, as described in the online documentation provided by Google.

我在我的 Android 应用程序中使用 Google Play 服务和 Admob 设置了广告,如 Google 提供的在线文档中所述。

I have added my device ID using addTestDevice("xxxxxxxxxxxxxxxx"), and have checked the hashed device ID a number of times to be sure it is correct.

我已经使用 addTestDevice("xxxxxxxxxxxxxxxx") 添加了我的设备 ID,并且已经多次检查散列的设备 ID 以确保它是正确的。

The Issue (see below for log info)

问题(有关日志信息,请参见下文)

When I run the application on my device, no ads are displayed at all. This happens even when I have added my device as a test device.

当我在我的设备上运行该应用程序时,根本没有显示任何广告。即使我将设备添加为测试设备,也会发生这种情况。

I have searched high and low, and turned up many similar issues, but am yet to find an answer to this specific problem.

我搜索了高低,发现了许多类似的问题,但还没有找到这个特定问题的答案。

LogCat Output

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

My Activity

我的活动

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

回答by pradeep.k

The issues comes only if that particular app is suspended from playstore. Maybe you can try changing the package name and and also with new Admob Id.There is a chance that particular admob id can also be suspended due to compliances.

只有当该特定应用程序从 Playstore 暂停时才会出现问题。也许您可以尝试更改包名称以及新的 Admob Id。由于合规性,特定的 admob id 也有可能被暂停。

回答by Red Cricket

I had this problem too. It wasn't until I went to Admob.com and "manually" added my app so I could get my "Ad Unit Id". I put this Ad Unit Id string as the argument my adView.setAdUnitIdcall. Then I installed and opened the "release" APK I generated via Eclipse. File > Export > Export Android Application

我也有这个问题。直到我去 Admob.com 并“手动”添加了我的应用程序,这样我才能获得我的“广告单元 ID”。我把这个 Ad Unit Id 字符串作为我adView.setAdUnitId调用的参数。然后我安装并打开了我通过 Eclipse 生成的“发布”APK。文件 > 导出 > 导出 Android 应用程序

回答by kalandar

If you create adunit and use it immediately may show this error, try to load ads after 30 minutes or more time.

如果您创建 adunit 并立即使用它可能会显示此错误,请尝试在 30 分钟或更长时间后加载广告。

回答by Adam Link

I had this issue as well today. My app was not suspended, but the apk name change did work. We had renamed a test app to release it to production; we changed the apk name as a result. This screwed up our ad fill on both MoPub and Admob.

我今天也有这个问题。我的应用程序没有被暂停,但 apk 名称更改确实有效。我们重命名了一个测试应用程序以将其发布到生产环境中;因此,我们更改了 apk 名称。这搞砸了我们在 MoPub 和 Admob 上的广告填充。

回答by Safwan Hijazi

Ads are disabled from Admob server, your code is ok, try to change the package name, and see if ads are displayed. Then contact admob to see the problem.

Admob服务器禁用广告,您的代码没问题,尝试更改包名称,看看是否显示广告。然后联系admob查看问题。

回答by Tushar Nallan

If your AdMob account is only configured for banner ads and you're using interstitial ads, you may get this problem. My 2 cents.

如果您的 AdMob 帐户仅针对横幅广告进行了配置,并且您使用的是插页式广告,则可能会遇到此问题。我的 2 美分。

回答by Orgatres

If you app support Designed for Families.

如果您的应用支持亲子同乐。

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

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

回答by raptors

In my case this was the error as result of requesting a geo-restricted ad from a region that's not supported for that ad. If I hardcoded the location for the ad request bundle to be inside the acceptable region, or not include a location in the request at all, the ad was rendered just fine; otherwise I had the same error as OP in console.

就我而言,这是由于从该广告不支持的区域请求受地理限制的广告而导致的错误。如果我将广告请求包的位置硬编码到可接受区域内,或者根本不包含请求中的位置,则广告呈现得很好;否则我在控制台中遇到与 OP 相同的错误。

回答by ahmadalibaloch

I was testing on Galaxy S4, later my friend tested on Note 2 and it did not show the banner ad. Hence the problem was test device Id. If you are testing then make sure the test device ID is of the device you are testing on.

我在 Galaxy S4 上进行测试,后来我的朋友在 Note 2 上进行测试,但没有显示横幅广告。因此,问题是测试设备 ID。如果您正在测试,请确保测试设备 ID 是您正在测试的设备的 ID。

回答by Suresh Kerai

it's also possible to luck of inventory. I am also face because of of this. failed to load ad : 3

存货的运气也是可能的。我也正因为这个面子。 无法加载广告:3