Admob实时广告未出现在libgdx应用程序中 - 未能加载广告:0 [英] Admob live ads not appearing in libgdx application - Failed to load ad: 0

查看:559
本文介绍了Admob实时广告未出现在libgdx应用程序中 - 未能加载广告:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用eclipse luna开发libgdx andriod应用程序,并尝试通过admob显示横幅广告。



我的应用运行良好并显示测试横幅广告没有问题。



当我将我的手机作为测试设备接收实时广告时,我在logcat中收到此错误:


 获取广告响应时出现问题。 ErrorCode:0 
无法加载广告:0


我已经在运行Android 6.0.1版的Galaxy Note 4和Samsung S5上测试了我的应用程序。在任一设备上都没有自定义ROM或广告拦截器,并且这两个测试广告都可以正常工作。

我跟着本指南的实施参考文献 google的Android指南



这里是我认为问题所在的地方。



通过我的SDK管理器,我安装了Google Play服务修订版本39和Google存储库修订版本。



本指南指出要附加位于以下位置的google-play-services_lib:


C:\ Users \ ... \AppData\Local\Android\sdk\extras\google\google_play_services

然而,在从这个问题的答案,我发现google-play-services_lib rev 29并将它添加到我的项目库中。如果SDK Manager中的Google Play服务修订版与我手动添加的修订版不同,那么它的修订版是否重要?

无论哪种方式,测试广告都可以正常工作,但我不确定,我是否错过了可能导致此错误的任何内容?



我还向谷歌组织(Google移动广告SDK开发人员)没有运气。



我的应用单元ID:


广告单元ID:ca-app-pub- 3059505755009716/4168523587

Ap ID:ca-app-pub-3059505755009716〜2178916381

我的Java实现(AndriodLauncher.java):

  public class AndroidLauncher扩展了AndroidApplication实现AdsController {

private static final String BANNER_AD_UNIT_ID =ca-app-pub-3059505755009716/416 8523587\" ;
// ca-app-pub-3059505755009716/8048823189
// ca-app-pub-3059505755009716/4168523587
AdView bannerAd;

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

//创建一个gameView和一个bannerAd AdView
查看gameView = initializeForView(new Boot(this),config);
setupAds();

//定义布局
RelativeLayout layout = new RelativeLayout(this);
layout.addView(gameView,ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(bannerAd,params);

setContentView(layout);
}

public void setupAds(){
bannerAd = new AdView(this);
bannerAd.setVisibility(View.GONE);
bannerAd.setBackgroundColor(Color.argb(0,0,0,0)); // black
bannerAd.setAdUnitId(BANNER_AD_UNIT_ID);
bannerAd.setAdSize(AdSize.BANNER); (){
}

@Override
public void showBannerAd(){
runOnUiThread(new Runnable(){
@Override
public void run ){
bannerAd.setVisibility(View.VISIBLE);
AdRequest.Builder builder = new AdRequest.Builder();


//builder.addTestDevice(
//builder.addTestDevice(\"ECDD91BD30440E7B3F4DA0E90F1D67A9);
AdRequest ad = builder.build();

bannerAd.loadAd(ad);
}
}); (){
}

@Override
public void hideBannerAd(){
runOnUiThread(new Runnable(){
@Override
public void run ){
bannerAd.setVisibility(View.INVISIBLE);
}
});


showBannerAd ()方法被调用:

  public Boot(AdsController adsController){
this。 adsController = adsController;
}

@Override
public void create(){
//Gdx.app.log (TITLE,started ..);

//展示广告(andriod launch)
adsController.showBannerAd();

setScreen(new Splash());
$ b $ Timer.schedule(new Task(){
@Override
public void run(){
assets = new Assets();
assets。 load();
assets.manager.finishLoading();

Audio.create();
Audio.bgm.play();
Audio.bgm。 setLooping(true);
setScreen(new MainMenu());
}
},3f);
}

AndriodManifest.xml

 <?xml version =1.0encoding =utf-8?> 
< manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.game
android:versionCode =1
android:versionName =1.0>

<使用权限android:name =android.permission.INTERNET/>
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>

< uses-sdk
android:minSdkVersion =9
android:targetSdkVersion =25/>

< application
android:allowBackup =true
android:icon =@ drawable / ic_launcher
android:label =@ string / app_name
android:theme =@ style / GdxTheme>
< activity
android:name =com.game.AndroidLauncher
android:configChanges =keyboard | keyboardHidden | orientation | screenSize
android:label =@ string / app_name
android:screenOrientation =landscape>
< intent-filter>

< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>
< activity
android:name =com.google.android.gms.ads.AdActivity
android:configChanges =keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize />

< meta-data
android:name =com.google.android.gms.version
android:value =@ integer / google_play_services_version/>
< / application>

< / manifest>

编辑:注意行

  compile'c​​om.google.android.gms:play-services-ads:10.0.1'

$ b

从build.grandle中的android依赖关系中丢失,刷新的依赖关系仍然没有实时广告。

解决方案根据Google



您最近可能只是创建了一个新的广告单元ID并请求实时投放广告。如果是这种情况,广告开始投放的时间只有几个小时,如果您收到测试广告,那么您的实施是正常的,只需等待几个小时,然后看看您是否能够接收实时广告;如果没有,可以向我们发送您的广告广告单元ID让我们看看。



https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo



等待几个小时。


I'm currently working on a libgdx andriod app using eclipse luna and attempting to display a banner ad through admob.

My app is running fine and displaying the test banner ads with no issues.

When I remove my phone as a test device to receive live ads I get this error in logcat:

There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0

I've tested my app on a Galaxy Note 4 and a Samsung S5 both running android version 6.0.1. There are no custom ROMs or ad blockers on either device and the test ads work on both.

I followed this guide on implementation with some references from google's android guide.

Here is where I think the issue is..

Via my SDK Manager I have Google Play services revision 39 and Google Repository revision 44 installed.

The guide says to attach the google-play-services_lib located at:

C:\Users\...\AppData\Local\Android\sdk\extras\google\google_play_services

However the file no longer exists, after following the information from this answer to the problem, I found google-play-services_lib rev 29 and added it to my projects library which works. Does the Google Play Services revision on the SDK Manager matter if its different from the one I manually added?

Either way this shouldn't matter as the test ads are working, however I'm not sure, have I missed anything that might be causing this error?

I also asked for assistance from google groups (Google Mobile Ads SDK Developers) with no luck.

My app unit ID:

Ad Unit ID: ca-app-pub-3059505755009716/4168523587

Ap ID: ca-app-pub-3059505755009716~2178916381

My Java implementation (AndriodLauncher.java):

public class AndroidLauncher extends AndroidApplication implements AdsController {

    private static final String BANNER_AD_UNIT_ID = "ca-app-pub-3059505755009716/4168523587";
    // ca-app-pub-3059505755009716/8048823189
    // ca-app-pub-3059505755009716/4168523587
    AdView bannerAd;

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

        // Create a gameView and a bannerAd AdView
        View gameView = initializeForView(new Boot(this), config);
        setupAds();

        // Define the layout
        RelativeLayout layout = new RelativeLayout(this);
        layout.addView(gameView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layout.addView(bannerAd, params);

        setContentView(layout);
    }

    public void setupAds() {
        bannerAd = new AdView(this);
        bannerAd.setVisibility(View.GONE);
        bannerAd.setBackgroundColor(Color.argb(0, 0, 0, 0)); // black
        bannerAd.setAdUnitId(BANNER_AD_UNIT_ID);
        bannerAd.setAdSize(AdSize.BANNER);
    }

    @Override
    public void showBannerAd() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                bannerAd.setVisibility(View.VISIBLE);
                AdRequest.Builder builder = new AdRequest.Builder();


                //builder.addTestDevice("9F2779F709CED00E2ADF6123C0D17A4C");
                //builder.addTestDevice("ECDD91BD30440E7B3F4DA0E90F1D67A9");
                AdRequest ad = builder.build();

                bannerAd.loadAd(ad);
            }
        });
    }

    @Override
    public void hideBannerAd() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                bannerAd.setVisibility(View.INVISIBLE);
            }
        });
    }
}

Snippet of where the showBannerAd() method is called:

public Boot(AdsController adsController){
    this.adsController = adsController;
}

@Override
public void create() {
//Gdx.app.log(TITLE, "started..");

// Display ads (andriod launch)
adsController.showBannerAd();

setScreen(new Splash());

Timer.schedule(new Task(){
    @Override
    public void run() {
        assets = new Assets();
        assets.load();
        assets.manager.finishLoading();

        Audio.create();
        Audio.bgm.play();
        Audio.bgm.setLooping(true);
        setScreen(new MainMenu());
    }
}, 3f);
}

AndriodManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.game"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="25" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >
        <activity
            android:name="com.game.AndroidLauncher"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

</manifest>

EDIT : Noticed the line

compile 'com.google.android.gms:play-services-ads:10.0.1'

was missing from the android dependencies within build.grandle, refreshed dependencies still no live ads.

解决方案

According to Google

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

so wait for a few hours.

这篇关于Admob实时广告未出现在libgdx应用程序中 - 未能加载广告:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆