Admob for Android gives error on AdActivity android:configChanges

After experimenting with Admob for Android, I came across an error with the example code that can be downloaded from the developer site about advertising.

The error Eclipse gave me, was:

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

ads-example-error

and that android:configChanges had to include screenLayout, uiMode, screenSize and smallestScreenSize.

After modifying the AdActivity tag in the Manifest file, from:

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

to including the missing config parameters:

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

I then got another error at the AdActivity, saying:

Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').

All permissions and everything was set up right in the code example, except for the project build target.

Apparently, some of the required parameters, are not supported in Android API versions lower than 13, but the build target specified in the example project, is set to API level 8.

So, open the project.properties file, and change target=android-8 to target=android-13 (or higher).

The example project should now be compiling and working properly, and displaying ads as expected.

ads-example

If Eclipse is still complaining about the last error, re-save the manifest file, or just restart Eclipse.

Ps: Remember to use your own admob_id in the strings.xml file.

comments powered by Disqus