0

I made an app that contains an Admob ads . I did everything as in the tutorial and everything was working fine until i put my own Ad id it didn't show . But when I change the Ad id to any ad id from the internet or from tutorials it works fine . I dunno where is the problem exactly .. is it from the codes or from my admob.

here is the codes :

    public class main extends Activity {
WebView web1;
private AdView mAdView;
InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    //full screen ads
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-4400857573550757/5605673426");
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            requestNewInterstitial();
        }
    });
    requestNewInterstitial();
    //---------------- START ORDERING BANNER ADD ------------
    // Initialize the Mobile Ads SDK.
   MobileAds.initialize(this, "ca-app-pub-4400857573550757/2713039825");
    mAdView = (AdView) findViewById(R.id.ad_view);
   AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

   // System.out.println(adRequest.isTestDevice(this))
    //---------------------------------------------------
   // mInterstitialAd.show();
    this.setRequestedOrientation(
            ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    final Handler handler = new Handler();
    Timer timer = new Timer();
    TimerTask doAsynchronousTask = new TimerTask() {
        @Override
        public void run() {
            handler.post(new Runnable() {
                public void run() {
                    try {
                        if (mInterstitialAd.isLoaded()) {
                            mInterstitialAd.show();
                        } else {
                           // beginPlayingGame();
                        }
                    } catch (Exception e) {
                    }
                }
            });
        }
    };

    timer.schedule(doAsynchronousTask, 0, 60000); //execute in every 10 ms

    web1 = (WebView) findViewById(R.id.webview);
    WebSettings webSettings = web1.getSettings();
    webSettings.setJavaScriptEnabled(true);
    web1.setWebViewClient(new WebViewClient());
    web1.loadUrl("MYWEBSITE");

    web1.setWebViewClient(new NoErrorWebViewClient());

}

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().build();
           // .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID")


    mInterstitialAd.loadAd(adRequest);
}}

and here is the layout codes :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:paddingBottom="1dp"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="1dp"
tools:context=".main">


<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />




<com.google.android.gms.ads.AdView
    android:id="@+id/ad_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-4400857573550757/2713039825" /></RelativeLayout>

I uploaded the log here : log

2 Answers2

0
09-03 08:14:53.186 2726-2726/muteb.speak I/Ads: Starting ad request.
09-03 08:14:53.190 2726-2726/muteb.speak I/Ads: Use AdRequest.Builder.addTestDevice("19AA808AE9FC61F7FA6E4AA2B99F2557") to get test ads on this device.
09-03 08:14:53.258 2726-2726/muteb.speak W/GooglePlayServicesUtil: Google Play services is missing.
09-03 08:14:53.262 2726-2726/muteb.speak W/GooglePlayServicesUtil: Google Play services is missing.
09-03 08:14:53.270 2726-2726/muteb.speak I/Ads: Starting ad request.
09-03 08:14:53.274 2726-2726/muteb.speak I/Ads: Use AdRequest.Builder.addTestDevice("19AA808AE9FC61F7FA6E4AA2B99F2557") to get test ads on this device.

See above logs... Device you are testing needs to be updated with Google Play Services library refer to this link Android Studio with Google Play: Google Play services is missing

Community
  • 1
  • 1
Amod Gokhale
  • 2,346
  • 4
  • 17
  • 32
  • I have tried putting a generated .Apk of my app on my updated Note4 still not working with me . Notice that other Ads Id works fine . – Muteb Asiri Sep 03 '16 at 18:27
0

Apparently, if JavaScript is enabled webSettings.setJavaScriptEnabled(true); the banner from AdMob will not work (at least in my case).

I couldn't find a workaround for this situation, but I am very much looking forward to hear others ideas.