gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 21:15:22 27 4
gpt4 key购买 nike

我的问题是我的应用中根本没有显示广告,无论是否处于测试模式。我将把这个问题专门用于测试模式,一旦我开始工作,我会担心直播广告。

发展信息

我正在使用 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

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

最佳答案

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

关于java - Admob 没有来自广告服务器的填充 - 无法加载广告 : 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26610383/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com