Is there anyone who has successfully implemented AdMob?

edited August 2017 in Android Mode

Is there anyone who has successfully implemented AdMob?

Tagged:

Answers

  • edited August 2017

    @jeremydouglass what's the android:value=" " in the manifest? where can I find this value?

  • You should definitely join that thread and/or talk to akenaton about that -- I've actually never used it myself.

  • @fish=== i explained that in the thread given by @jeremydouglass

  • Thanks! @akenaton I was also wondering how to add a test device by ID, I've tried to add the line .addTestDevice("D******"); above the .build(); in the onCreate, but I get a type mismatch, com.google.android.gms.ads.AdRequest.Builder does not match with com.google.android.gms.ads.AdRequest.

  • @fish===

    can you put the code you are no using??? - i am not sure about you have done...

  • edited August 2017
    import android.os.Looper;
    import android.os.Bundle;
    import android.view.Window;
    import android.widget.RelativeLayout;
    import android.app.Activity;
    import com.google.ads.*;
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.AdView;
    import com.google.android.gms.ads.AdSize;
    import com.google.android.gms.ads.MobileAds;
    
    
    
    
    
    void setup() {
      fullScreen();
    
    }
    
    
    void draw() {
      background(53);
    
    }
      @ Override
      public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
      Window window = getActivity().getWindow();
       RelativeLayout adsLayout = new RelativeLayout(this.getActivity());
       RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
          RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);  
    
      AdView adView = new AdView(this.getActivity());
    
      adView.setAdSize(AdSize.BANNER);
      adView.setAdUnitId("ca-app-pub-2_______________/7_________");
        adsLayout.addView(adView);
          AdRequest newAdReq = new AdRequest.Builder()
    
          .build();
          adView.loadAd(newAdReq);
          window.addContentView(adsLayout,lp2);
    
    
    
      }
    
  • edited August 2017
    **<?xml version="1.0" encoding="UTF-8"?>
    <manifest xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="">
      <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15"/>
      <application android:debuggable="true" android:icon="@drawable/icon" android:label="">
        <activity android:name=".MainActivity" android:theme="@android:style/Theme.NoTitleBar">
          <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"/>
        <meta-data android:name="com.google.android.gms.version" android:value="8298000"/>
      </application>
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
      <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
      <uses-permission android:name="android.permission.INTERNET"/>
      <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    </manifest>
    **
    
  • @akenaton I have two problems, the first one is that, I get a banner that says"missing adactivity with android.configchanges in androidmanifest.xml" instead of the ads... and then secondly I wanted to add test ads by adding .addTestDevice("blahblah") line 40, but it didn't work :(

  • @fish===

    • your Manifest is missing the requested configchanges attributes; add this line:

       android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      
    • why are you targetting only 15 ( i dont speak about the minSdk)???

    -what says the error log when adding .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) line 40???

  • edited September 2017

    @akenaton Thanks, I have added the line that I missed and corrected the the target sdk(Thanks for pointing that out!)

    For the .addTestDevice(" your device id"), I realised that I was getting the error because I did not quote the ID "". Now there's no error,

    however when I test it, there is no ads that appear.. is that normal? do the ads only show if you get the app on the play store?

  • Use test Banner ID: ca-app-pub-3940256099942544/6300978111
    Interstitial ca-app-pub-3940256099942544/1033173712
    Rewarded Video ca-app-pub-3940256099942544/5224354917
    View details

  • It works! Thanks!

  • @akenaton but... the ads only show after the screen has been in sleep mode. They don't appear right away when you open the app

  • edited September 2017

    @fish===

    are you testing or working in (real) device mode?

    and try to add code in onResume();

  • yes it is on a real device

Sign In or Register to comment.