Admob Error in Eclipse for android:configChanges
Asked Answered
G

7

132

Eclipse is giving me an error on the android:configChanges line in my AndroidManifest.xml:

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

the error is:

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

If I leave only keyboard|keyboardHidden|orientation there's no error, but compiler asks for the 4 remaining ones when I try and build.

I'm using GoogleAdMobAdsSDK-4.3.1.

Any ideas?

EDIT: I got it working by changing my project.properties (default.properties on SDK's lower then 14) file to:

# Project target.
target=android-14

and in my SDK Manager having the SDK Platform Android 4.0 - Revision 14 installed.

It should also work for SDK Platform android 3.2 - revision 13, so you just have to change the project.properties target to android-13 if that is the case. Basically you just have to make sure that the SDK revision is 13 or above, and that you have that SDK installed in the SDK manager and the project target in default/project.properties pointing to it.

Gewgaw answered 26/10, 2011 at 7:21 Comment(5)
which android version do you use?Macruran
Min SDK version 7 - Android 2.1Gewgaw
I tried changing the target to 13, but it is not working .. what could be the reason ?Plier
@anirudhmaddy did you use "android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" or shorter one? If you change your target above 13 and use longer configChanges one, it should work.Roesler
@gurcan15 yup its working now.Plier
M
74

Simple answer: the mentioned config changes are not support in Android 2.1, have a look here:

http://developer.android.com/guide/topics/manifest/activity-element.html#config

e.g. uiMode needs API Level 8.

From the official AdMob Documentation:

Requirements

The Google AdMob Ads SDK for Android requires Android 1.5 or later. Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in default.properties to android-13).

have a look here: https://developers.google.com/admob/android/quick-start

So I think your tools version is not updated to at least Version 13.

Macruran answered 26/10, 2011 at 7:33 Comment(16)
I changed <uses-sdk android:minSdkVersion="7"/> to version 8, 9, 10, 11, 12... still have the error... also tried removing the line and it still gives me the error.Gewgaw
screenSize and smallestScreenSize are only supported in API Level 13, which means Honeycomb, are you sure you need them? As they are quite Honeycomb specific.Macruran
Well if I don't declare them I get this in LogCat: 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. And where the ad is meant to be I get a black box with the last error message written in red in it.Gewgaw
I've added a quite important note from the SDK to my response above.Macruran
Okay my default.properties target is android-7, I change to 13, and it says Unable to resolve target 'android-13'. I have "Android SDK Tools, revision 13" installed in my SDK manager though...Gewgaw
you need to have the 3.2 target installed also.Macruran
Got it working with the new revision 14 for IceCreamSandwich. ThanksGewgaw
Can I asked you to post just how you got this working so far the only luck I've had is setting the project api level to Android 3.2 or is this what you did?Farflung
Hopefully my EDIT in the original post gives enough extra detail on getting it working to help you.Gewgaw
So AdMob will only work on newer phones? I would be cutting out any users with older phones, including me.Marucci
No, you only need to compile at least against Android 3.2, but that doesn't lock out older devices (this is configured in the manifest).Macruran
i have simple Question Can i use google GoogleAdMobAdsSdk-6.0.1.jar to show ads on android 2.2 ,Because our application need to run on android 2.2 and higher.Enhanced
If i set target=android-13 then i see that it can only run with android 3.2 ,am i right? if any thing wrong let me known.Enhanced
Can You please answer this question #25916336 ?Jonathonjonati
I have an admob question: #36390229Sera
The link is brokenThelma
T
86

Easy solution: (and NO you don't need to to change the min-sdk value !!)

Step 1: Change "project.properties" file

# Project target.
target=android-13

Step 2: In Eclipse

Project > Clean... > (select your project) > Clean projects selected below > OK

For a complete explanation with real example use this tutorial http://www.monkeycoder.co.nz/Community/posts.php?topic=1121

Cheers !

Thorwald answered 6/2, 2012 at 22:17 Comment(1)
Excellent! I too was using sdk7 albeit the google api version. So I used # Project target. target=Google Inc.:Google APIs:13 in my properties file.Juttajutty
M
74

Simple answer: the mentioned config changes are not support in Android 2.1, have a look here:

http://developer.android.com/guide/topics/manifest/activity-element.html#config

e.g. uiMode needs API Level 8.

From the official AdMob Documentation:

Requirements

The Google AdMob Ads SDK for Android requires Android 1.5 or later. Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in default.properties to android-13).

have a look here: https://developers.google.com/admob/android/quick-start

So I think your tools version is not updated to at least Version 13.

Macruran answered 26/10, 2011 at 7:33 Comment(16)
I changed <uses-sdk android:minSdkVersion="7"/> to version 8, 9, 10, 11, 12... still have the error... also tried removing the line and it still gives me the error.Gewgaw
screenSize and smallestScreenSize are only supported in API Level 13, which means Honeycomb, are you sure you need them? As they are quite Honeycomb specific.Macruran
Well if I don't declare them I get this in LogCat: 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. And where the ad is meant to be I get a black box with the last error message written in red in it.Gewgaw
I've added a quite important note from the SDK to my response above.Macruran
Okay my default.properties target is android-7, I change to 13, and it says Unable to resolve target 'android-13'. I have "Android SDK Tools, revision 13" installed in my SDK manager though...Gewgaw
you need to have the 3.2 target installed also.Macruran
Got it working with the new revision 14 for IceCreamSandwich. ThanksGewgaw
Can I asked you to post just how you got this working so far the only luck I've had is setting the project api level to Android 3.2 or is this what you did?Farflung
Hopefully my EDIT in the original post gives enough extra detail on getting it working to help you.Gewgaw
So AdMob will only work on newer phones? I would be cutting out any users with older phones, including me.Marucci
No, you only need to compile at least against Android 3.2, but that doesn't lock out older devices (this is configured in the manifest).Macruran
i have simple Question Can i use google GoogleAdMobAdsSdk-6.0.1.jar to show ads on android 2.2 ,Because our application need to run on android 2.2 and higher.Enhanced
If i set target=android-13 then i see that it can only run with android 3.2 ,am i right? if any thing wrong let me known.Enhanced
Can You please answer this question #25916336 ?Jonathonjonati
I have an admob question: #36390229Sera
The link is brokenThelma
D
18

For those using Eclipse there is an easier way: Right click your project folder in the left "Package Explorer" pane and click Properties -> Android -> and in the "Project Build Target" list check off API 13 or up.

Note: this is the same effect as editing project.properties which is auto-generated anyway.

This will build your project against the Android 3.2 SDK which includes the terms that were previously unrecognized.

You may leave your android:minSdkVersion and targetSdkVersion values the same in your Manifest.xml.

Be warned though, if you don't set your targetSdkVersion to API 12 or lower (or don't set it at all) the Android system will assume that the android:configChanges values screenSize and smallestScreenSize (which were introduced in API 13) are accounted for and thus will be allowed to destroy-restart your activity. If you wanted to avoid this you must include those terms in your other <activity> tags (which probably only had keyboard|keyboardHidden|orientation until now).

However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

Quote is from here.

Danika answered 10/2, 2012 at 22:46 Comment(0)
C
3

I had the same problem so I came here.
I have downloaded the sample code from https://developers.google.com/admob/android/quick-start, I still had the problem with all answers above so I used the same admob sdk, they offer in the sample project. Redo the build jars thing, changed target to android-15, and used the same line they use:

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

And it works!

Coss answered 12/3, 2012 at 14:3 Comment(1)
I think that is the way to go. Because, for me, since Asynctasks are broken from API whatever onwards (they use now a sequential executor instead of a parallel one because they had 'issues' with the parallel one), I rather use an old target than having to modify by hand the default executor...Waites
B
0

Did you use android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|‌​screenSize|smallestScreenSize

or shorter one? If you change your target above 13 and use longer configChanges one (which I wrote), it should work.

Bainmarie answered 15/1, 2013 at 16:28 Comment(0)
E
0

Easy solution: Change "project.properties" file to 21

# Project target.
target=android-21
Elviraelvis answered 11/4, 2015 at 11:58 Comment(0)
R
-4

All new Android apps created after October 14, 2011 will require an AdMob SDK that was released on or after March 15, 2011. This corresponds to version 4.0.2+ for Android. If you downloaded the library from our official download site, then you're already set. Otherwise you may have an old version of the AdMob SDK that was released prior to March 15, 2011, and your new app will not receive any ad impressions until you update your SDK.

Rioux answered 24/11, 2011 at 10:1 Comment(1)
You just copy-pasted stuff from the Inter net without understanding it. This has no relevance to the actual problem.Internationalist

© 2022 - 2024 — McMap. All rights reserved.