2

I'm trying to integrate admob for the first time. I followed the documentation rules here, and I've seen several related pages, but I still seem to be doing something wrong.
I'm using GoogleAdMobAdsSdk-6.1.0.jar, as well as android sdk version 13 (Android 3.2).

I included several things that I've found are required from various sources.

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="13" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScre‌​enSize"  />

in my AndroidManifest.xml.

I included

target=android-13

in my project.properties.

The above configuration does not compile. I get an error in eclipse (Version: 4.2.0) stating the following:

error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScre‌​enSize'

If I change it to the old style

android:configChanges="keyboard|keyboardHidden|orientation"

the project compiles just fine, but when I get to my activity I have the following problem:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/Aqua"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/adLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </LinearLayout>

</LinearLayout>

The code in my activity looks like this:

public class TutorialActivity extends Activity {

    private static final String PUBLISHER_ID = "blah"; //omitted
    private AdView adView;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.tutorial_layout);
        AdRequest request = new AdRequest();
        request.addTestDevice("what i believe is my device id");

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

        LinearLayout layout = (LinearLayout) findViewById(R.id.adLayout);
        layout.addView(adView);
        adView.loadAd(request);
    }

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

}

When I run this code and navigate to my activity, I see what looks to be an ad box at the top of the screen as I would expect, and inside it is the following text: You must have AdActivity declared in AndroidManifest.xml with configChanges.

I am one confused individual. This is the very last thing I'd like to include in my app before releasing it to the google app store, and any advice or help is much appreciated. I apologize if I've left anything out.

Community
  • 1
  • 1
farkerhaiku
  • 259
  • 3
  • 12
  • Duplicate of http://stackoverflow.com/questions/11208729/error-string-types-not-allowed-at-androidconfigchanges-in-manifest-file – arkon May 03 '13 at 06:37

1 Answers1

8

I had the same problem. I will tell you what I did.

right click on the project folder in eclipse

  • -properties
  • -choose android
  • -choose firmware 3.2 or higher

and then use this in the manifest

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"

thats all

Hossam Alaa
  • 663
  • 5
  • 9
  • If you couldnt find 3.2 or higher then just download it from the sdk manager – Hossam Alaa Aug 18 '12 at 05:03
  • 1
    I have no idea why this worked, since this was exactly what options I already had enabled, but it did work. I went into properties, chose android, saw that I had already selected 3.2, but when I hit Ok, the compile error went away. Thanks so much! This borders on magic less than science, but I appreciate the assist. I'll accept your answer in 2 minutes when SO allows it. – farkerhaiku Aug 18 '12 at 05:09
  • hahaha =D I know how you feel. You were having this problem because of that OK button.Seriously, Eclipse is really stupid!! – Hossam Alaa Aug 18 '12 at 05:26
  • Too bad your app is now incompatible with anything prior to 3.2 – arkon May 03 '13 at 06:35
  • you can set minSDK in the AndroidManifest.xml !! – Hossam Alaa Jun 09 '13 at 17:15