【问题标题】:Android admob test device not workingAndroid admob 测试设备不工作
【发布时间】:2012-02-06 17:36:28
【问题描述】:

我正在尝试将 admob 实现到我正在制作的应用程序中。在模拟器上测试广告时,广告显示正常,但在实际设备上测试时,没有广告。

设备的Logcat:

02-06 17:27:56.696: I/Ads(3280): Unable to connect to network: com.google.ads.c$d: NETWORK_ERROR
02-06 17:27:56.736: D/AndroidInput(3280): sensor listener setup
02-06 17:27:56.806: D/PhoneWindow(3280): couldn't save which view has focus because the focused view com.badlogic.gdx.backends.android.surfaceview.DefaultGLSurfaceView@4052d560 has no id.
02-06 17:27:56.816: D/AndroidInput(3280): sensor listener tear down
02-06 17:27:56.826: W/webcore(3280): hasMessages() is not supported in this case.
02-06 17:27:56.826: W/webcore(3280): hasMessages() is not supported in this case.
02-06 17:27:56.836: I/Ads(3280): onFailedToReceiveAd(A network error occurred.)

这是我的java代码:

public class HoodStarGame extends AndroidApplication {
@Override public void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Create the layout
    RelativeLayout layout = new RelativeLayout(this);

    // Do the stuff that initialize() would do for you
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    // Create the libgdx View
    View gameView = initializeForView(new HoodStar(), false);

    // Create and setup the AdMob view
    AdRequest request = new AdRequest();
    request.addTestDevice(AdRequest.TEST_EMULATOR);
    request.addTestDevice("7ADDEC88A42947CD1FD7F2EC2F527485");

    AdView adView = new AdView(this, AdSize.BANNER, "a14f19c2fe8d9e0"); // Put in your secret key here
    adView.loadAd(request);

    // Add the libgdx view
    layout.addView(gameView);

    // Add the AdMob view
    RelativeLayout.LayoutParams adParams = 
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                            RelativeLayout.LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_BASELINE);

    layout.addView(adView, adParams);

    // Hook it all up
    setContentView(layout);
}
}

正如我所说,我已经尝试在模拟器中运行并且效果很好,我的设备是 2.3.3,与我测试过的模拟器相同。

有人知道怎么回事吗?

【问题讨论】:

  • 您的网络是否在您的设备上运行? (您可以浏览 ads.google.com 吗?)
  • 是的,我的网络工作正常,但我只能通过 wifi 连接,而不是 3g 网络,这可能是问题吗?
  • 代码正确。这绝对是网络异常;我假设您在确认可以访问 google.com 后尝试请求广告?

标签: android admob libgdx


【解决方案1】:

您的主机文件阻止了大多数广告服务器。您可能应该删除它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多