我正在尝试将admob应用到我正在制作的应用中。在模拟器上测试广告时,广告显示正常,但在实际设备上进行测试时,没有广告。
Logcat for device:
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,这与我测试过的模拟器相同。
任何人都知道什么了?
答案 0 :(得分:0)
您的主机文件阻止了大多数广告服务器。你应该删除它。