Admob Error in Eclipse for android:configChanges

2019-01-03 05:03发布

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.

7条回答
叼着烟拽天下
2楼-- · 2019-01-03 05:28

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

# Project target.
target=android-21
查看更多
爷的心禁止访问
3楼-- · 2019-01-03 05:36

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.

查看更多
神经病院院长
4楼-- · 2019-01-03 05:38

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.

查看更多
在下西门庆
5楼-- · 2019-01-03 05:38

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 !

查看更多
孤傲高冷的网名
6楼-- · 2019-01-03 05:41

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.

查看更多
倾城 Initia
7楼-- · 2019-01-03 05:44

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!

查看更多
登录 后发表回答