0

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.

Community
  • 1
  • 1
BT93
  • 329
  • 2
  • 9
  • 25

1 Answers1

1

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.

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65
  • I have had the ap unit id for 3 days. I've posted to the forum you mentioned and was told that my app id is producing live ads according to their tests. – BT93 Mar 09 '17 at 09:55
  • try changing ads:adSize="BANNER" with ads:adSize="SMART_BANNER" – Abhishek Aryan Mar 09 '17 at 09:59
  • I've used SMART_BANNER, BANNER and LARGE_BANNER all options display test ads no problem. When I comment out the addTestDevice() to get live ads I get the same error. – BT93 Mar 09 '17 at 10:09
  • still having same problem try to change adUnitId in adMob account and use it in your app. or again issues persist, create new app (just change the name) in adMob and create new keys – Abhishek Aryan Mar 10 '17 at 06:24
  • I just archived the old ID made a new one and also created a new app with new ID, both new IDs produce only test ads. I'm going to try some sample apps to see if live ads are being generated to make sure its not my implementation. I still think it has something to do with my google-play-services rev. – BT93 Mar 10 '17 at 06:36
  • you can check this project https://github.com/itsabhiaryan/AdService-LibGDX, may be it give some help – Abhishek Aryan Mar 10 '17 at 06:40
  • have you added uses-permission for INTERNET and ACCESS_NETWORK_STATE in Manifest file?? – Abhishek Aryan Mar 10 '17 at 06:43
  • Yeah, added AndriodManifest.xml ^ – BT93 Mar 10 '17 at 06:46
  • I don't understand, when I use your sample app with my app ID, live ads appear. However still cannot get live ads to appear on my app. It must be something to do with how I've implemented my ads. Trying to compare implementations now.. – BT93 Mar 10 '17 at 09:16
  • have you got your mistake ? – Abhishek Aryan Mar 10 '17 at 17:49
  • Sort of, I created a new libgdx project and imported it into eclipse, then I copied my ad implementation from my original app and it worked. Not sure where the problem was but creating a new project fixed it. – BT93 Mar 12 '17 at 13:25
  • Thanks for your help and the sample project! – BT93 Mar 12 '17 at 13:29