Can't get google play services ads to work.

204 views
Skip to first unread message

Hunky Dory Applications

unread,
Aug 12, 2014, 10:33:22 PM8/12/14
to google-adm...@googlegroups.com
In short I have tried both pragmatically and through xml adding a banner add to my app, but I am unable to get it to work. I have tried everything I can find on the internet. I have been looking for an answer for over a month now. 
When I try to add the ad through xml I get a java.lang.verifyError.
When I try to add the banner pragmatically I get "no fill from ad server. failed to load ad: 3" in my logcat.
I started a hello world app to try and figure this out.
Here is the entire code from my main and only activity.


package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import android.widget.LinearLayout;


public class MainActivity extends Activity {
/** The view to show the ad. */
 private AdView adView;

 /* Your ad unit id. Replace with your actual ad unit id. */
 private static final String AD_UNIT_ID = "ca-app-pub-7467992693236632/6185806558";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
     // Create an ad.
        adView = new AdView(this);
        adView.setAdSize(AdSize.BANNER);
        adView.setAdUnitId(AD_UNIT_ID);
        adView.setBackgroundColor(-16777216);

        // Add the AdView to the view hierarchy. The view will have no size
        // until the ad is loaded.
        LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout2);
        layout.addView(adView);

        // Create an ad request. Check logcat output for the hashed device ID to
        // get test ads on a physical device.
        AdRequest adRequest = new AdRequest.Builder()
        /*.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
        .addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB")
        .addTestDevice("91F6C527213BE2F10B59FF65516D8FD3")*/
        .build();
        

        // Start loading the ad in the background.
        adView.loadAd(adRequest);
        

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    
    @Override
    public void onResume() {
      super.onResume();
      if (adView != null) {
        adView.resume();
      }
    }

    @Override
    public void onPause() {
      if (adView != null) {
        adView.pause();
      }
      super.onPause();
    }

    /** Called before the activity is destroyed. */
    @Override
    public void onDestroy() {
      // Destroy the AdView.
      if (adView != null) {
        adView.destroy();
      }
      super.onDestroy();
    }
}

The code from my manifest:

<?xml version="1.0" encoding="utf-8"?>
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
         <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <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"/>
    </application>
</manifest>

And the code from my xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test.MainActivity" >

     <!-- <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-7467992693236632/2952065752" /> -->

    <!-- <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" /> -->

</LinearLayout>

Thanks in advance for any help anybody can give me.

Albert Gazetdinov

unread,
Aug 13, 2014, 1:53:15 AM8/13/14
to google-adm...@googlegroups.com
If you can not create your project with advertising, then create a project based on a sample extras\google\google_play_services\samples\admob\
Make sure it is working. Step by step to remove unnecessary code. Check your work after each changes. Use basic production code with advertising as the basis for your development. I hope you understand the logic.
I also did not understand the first time. But used the example and I had success.

среда, 13 августа 2014 г., 5:33:22 UTC+3 пользователь Hunky Dory Applications написал:

Eric Leichtenschlag

unread,
Aug 13, 2014, 6:38:53 PM8/13/14
to google-adm...@googlegroups.com
Is this error when you're running it, or just viewing it in Eclipse's XML visual layout? That doesn't look like an Android stack trace.

Do you get no fill even when you uncomment the test devices lines?

William Ferguson

unread,
Aug 13, 2014, 7:45:12 PM8/13/14
to google-adm...@googlegroups.com

Hunky Dory Applications

unread,
Aug 14, 2014, 2:31:48 PM8/14/14
to google-adm...@googlegroups.com
Here is a screenshot of the test app running on my phone. It looks the same in the emulator. I made the background black so that you can see where the ad should be. If I only try to implement the ad through xml when I switch from my xml view to the graphical layout in eclipse it gives me a "adView could not be instantiated error." ...as shown in the above second screenshot. 
Screenshot_2014-08-14-14-20-39.png
eclipse ad test app error.png

Hunky Dory Applications

unread,
Aug 14, 2014, 2:41:25 PM8/14/14
to google-adm...@googlegroups.com
That is correct Eric, I get a no fill even when I uncomment the test device lines. Also, to answer your first question, I get the no fill error when I try to implement the ad pragmatically. When I try to implement the ad through xml, I am not even able to compile my app .  

Thanks for the link William. I have seen that on stackoverflow while I was researching, but I decided to include it anyway because I'm not getting anything else to show why my ad is always reporting a no fill. Since uncommenting out the test device lines does not change the anything I am guessing my problem is something else.
Message has been deleted

Hunky Dory Applications

unread,
Aug 15, 2014, 10:44:13 AM8/15/14
to google-adm...@googlegroups.com
Here is a screenshot of my adMob account from the other day when I was working on this. As you can see it's sending the requests to the server, but that's all it's doing.
adMob screenshot.png

Eric Leichtenschlag

unread,
Aug 15, 2014, 4:09:34 PM8/15/14
to google-adm...@googlegroups.com
Can you provide a link to the play store to your app that's not serving ads?

Hunky Dory Applications

unread,
Aug 15, 2014, 8:36:05 PM8/15/14
to google-adm...@googlegroups.com


--

---
You received this message because you are subscribed to a topic in the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/7EL6dA2UHXI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Leichtenschlag

unread,
Aug 18, 2014, 1:26:42 PM8/18/14
to google-adm...@googlegroups.com
Thanks. Now what do I have to do to start getting ads in the app? I opened it up and started a timer, but the logs don't show any indication of an ad request even being made.

Thanks,
Eric
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Hunky Dory Applications

unread,
Aug 18, 2014, 5:14:58 PM8/18/14
to google-adm...@googlegroups.com
That is correct. Currently in my source code I have all the ad code commented out. Since I couldn't get the ads to work I published the app without ads. I did add all the required permissions so that when I do get it working the app will automatically update. 

Also, one thing I found out is that I compiled the google adMob exapmle found in the google play services folder in the android sdk folder and that works. Although it also has all the same errors I'm relieving now too. In the example the xml resource still has the adView class can't be instantiated error and the hard code is exactly the same as my code but it works for some reason. 
Reply all
Reply to author
Forward
0 new messages