1
\$\begingroup\$

Can anyone help me integrating Admob to my game. I've used the badlogic framework by MarioZencher ... and My game is like the SuperJumper. I am unable to use AdMob after a lot of my attempts. I am new to android dev...please help me..I went thru a number of tutorials but not getting adds displayed ...

I did the following...

  1. get the libraries and placed them properly
  2. My main.xml looks like this

    android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

  1. My Activity class onCreate method:

    public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    RelativeLayout layout = new RelativeLayout(this);
    adView = new AdView(this, AdSize.BANNER, "a1518637fe542a2");
    AdRequest request = new AdRequest();
    request.addTestDevice(AdRequest.TEST_EMULATOR);
    request.addTestDevice("D77E32324019F80A2CECEAAAAAAAAA");    
    adView.loadAd(request);
          layout.addView(glView);
          RelativeLayout.LayoutParams adParams =
                  new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                  RelativeLayout.LayoutParams.WRAP_CONTENT);
          adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
          adParams.addRule(RelativeLayout.CENTER_IN_PARENT);
          layout.addView(adView, adParams);
          setContentView(layout);
    
    
    
    
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
    glView = new GLSurfaceView(this);
    glView.setRenderer(this);
    //setContentView(glView);
    
    glGraphics = new GLGraphics(glView);
    fileIO = new AndroidFileIO(getAssets());
    audio = new AndroidAudio(this);
    input = new AndroidInput(this, glView, 1, 1);
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");        
    

    }

  2. My Manifest file looks like this ....

    <activity android:name="com.google.ads.AdActivity"
      android:configChanges="keyboard|keyboardHidden|orientation|smallestScreenSize"/>

</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="7" />

When I first decided to use the XML for admob purpose ..it showed no changes..it even didn't log the device id in Logcat...

Later when I wrote code in the Main Activity class.. and run ... Application crashed ... with 7 errors evry time ...

The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.

The android:configChanges value of the com.google.ads.AdActivity must include uiMode.

The android:configChanges value of the com.google.ads.AdActivity must include screenSize.

The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.

You must have AdActivity declared in AndroidManifest.xml with configChanges.

You must have INTERNET and ACCESS_NETWORK_STATE permissions in AndroidManifest.xml.

Please help me by telling what wrong is there with the code? Can I write code only in xml files without changing the Activity class ... I will be very grateful to anyone providing support.

\$\endgroup\$
  • \$\begingroup\$ Have you tried making the changes which the error messages indicate are necessary to your manifest file? \$\endgroup\$ – BRPocock Feb 1 '14 at 11:59
1
\$\begingroup\$

You need to add the admob activity to your android manifest.. The following question has a good example:

https://stackoverflow.com/questions/10214308/android-admob-how-to-declare-adactivity-in-manifest

        <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
\$\endgroup\$
  • \$\begingroup\$ Yes.. it's already added.... \$\endgroup\$ – Vishal Kumar May 7 '13 at 4:38
  • 1
    \$\begingroup\$ You're missing screenLayout|uiMode, and you also need to add: INTERNET and access NETWORK STATE \$\endgroup\$ – wes May 7 '13 at 11:43
  • 1
    \$\begingroup\$ <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> \$\endgroup\$ – wes May 7 '13 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.