pearmak pearmak - 1 year ago 102
Android Question

android admob id

i am very new to the android app development, and i have just almost completed one app finally, and now i am trying to add admob to the app in order to show the ad undernearth.

i have installed that version 6.1.0 and also downloaded the example from google at and there is one line

adView = new AdView(this, AdSize.BANNER, AD_UNIT_ID_GOES_HERE);

that has bug AD_UNIT_ID_GOES_HERE highlighted.

  1. is that i must replace the above AD_UNIT_ID_GOES_HERE by registering and getting an admob account? I have not registered any admob account yet.

  2. Is that then i cannot test and preview about the ad if i have no true admob account? are there any ID available solely for testing purposes before i really register for a real one?

The java code is solely copied from the above google website and pasted as follows. android manifest and xml are also same as those in the google example.



import android.os.Bundle;
import android.widget.LinearLayout;

* A simple {@link Activity} that embeds an AdView.
public class BannerSample extends Activity {
/** The view to show the ad. */
private AdView adView;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

// Create an ad.
adView = new AdView(this, AdSize.BANNER, AD_UNIT_ID_GOES_HERE);

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

// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest();

// Start loading the ad in the background.

/** Called before the activity is destroyed. */
public void onDestroy() {
// Destroy the AdView.
if (adView != null) {


Answer Source

Just make yourself an account. It's free!

You can't show ads without an publisher id.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download