Error with admob banners [duplicate] - android

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.

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 !

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.

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.

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!

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.

Easy solution:
Change "project.properties" file to 21
# Project target.
target=android-21

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.

Related

Google Play Services : target=android-19 in project.properties

I am utilizing the library BaseGameUtils and google-play-services_lib. In the project.properties file I could see the below mentioned line .
target=android-19.
What is the significance of this? Can I change this to "target=android-21". This is just to be in sync with the App's manifest file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
Yes. You can change this, Depending target only, packages load for you in eclipse.
What is the significance of target=android-19?
target = android-X in project properties file means that Eclipse will not allow use methods or classes from SDK higher than X. It will show compiler errors.
How to change target:
Right click your project.
Then click "Properties".
Then select "Android" from the tree on the left.
You can then select the target version on the right.
NOTE: Before doing this make sure your project.properties and classpath are not in read-only mode otherwise it won't work. Also don't try to edit this file manually.
As a general rule I use the following guidelines
android:minSdkVersion="8"
Set this to the minimum level you want to support. Check which Android version that it actually relates to and make sure that you have compatibility with that version. For example, I think 8 = Android 2.2, which could be a problem if you are using google play services libraries. It is good practice to at least test that you app will work properly on this version using the emulator, because otherwise you will get a lot of errors and bad reviews.
android:targetSdkVersion="21" />
I usually set this to the maximum version that I have actually tested my app on. I thin 21 is Android 4.4, so you should be making sure that your app works correctly on this version of Android. At the least, you should test that it will run in an emulator that is configured with this version of Android.
Hope this helps.

Why is AdMob integration in my app using Android Studio not working?

I integrated AdMob in my app using Eclipse Juno - it is working fine. But when I tried to integrate it using Android Studio, I get this error:
Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').
I also added jar file in libs folder. I use minSdk =9 and targetSdk=18. I also changed project.properties file to "target=android-13".
screenSize and smallestScreenSize were only added in API 13. See http://developer.android.com/guide/topics/manifest/activity-element.html#config
I presume you are getting this error when building the app? Change your build config so that you are building against version 13 or up of the SDK.
Check your target api level and minimum api level. i had similar issue before and i solved it like this:
target api level = highest available
minimum api level = 9
I dont know much about Android studio but you can do it from manifest.xml
i hope it helps.

targetSdkVersion not similar in android manifest as selected while project creation

I am creating a project in android using eclipse.
Now my problem is when i create a android application project, I set Build Sdk version to 4.1 (API 16). But when i saw in manifest file the android:targetSdkVersion="15" . Can anyone explain me why this is happening ? see the below screenshots.
Thanks in advance
Updated Answer:
Here it goes,
Solution is,
goto:
Your
Directory\android-sdk-windows\tools\templates\projects\NewAndroidApplication\root
Open :
AndroidManifest.xml.ftl File
Change :
default :
<uses-sdk android:minSdkVersion="${minApi}"
android:targetSdkVersion="${targetApi}" />
Modified :
<uses-sdk android:minSdkVersion="${minApi}"
android:targetSdkVersion="${buildApi}" />
So the Problem goes here:
In the ftl file the attribute name ${targetApi} has been set, but we are selecting the buildApi value in the project creation window.
${targetApi} or ${buildApi} default value is the higher version , that means in your SDK tool it is API 15. So it is always 15 in the Manifest.
If you tried to create a new project with target API less than 10 or more than 15 anything , in the manifest it will be denoted as 15 only always.
Try this:
Create a project with API target 8 and see , manifest target will be 15 only. (Before modify the ftl file).
But project.properties has been updated properly.
So if you change ${targetApi} to ${buildApi} in the Manifest.xml.ftl, the problem solved.
It is a possible error in SDK tools revision 20, Even i updated the SDK tools itsn't resolved in the recent revision also.
Hope this one might be helpful for somebody, those who facing the same.
Older Answer:
It is showing for me too. But in my case, I selected API 14 and it is showing android:targetSdkVersion="15" in the manifest.
I guess some reason should be there... 4.0 or 4.2 , it is assigning 4.1 in the manifest... Or may be a bug with Eclipse IDE. Why cant you update the newer version of Eclipse IDE and try it out. This might be a IDE Problem only.
Can you see that Right click- Properties - Android , Checked one is same what you selected in the beginning.
And also project.properties has the same version what you selected in the beginning.
well the Project target you set is got set in the default.properties file if you change that and save it the the attached sdk will change you can try it.
the entry in menifiest is used after compilation on the device . don't know why it is taking wrong value.but in my eclipse it takes only minsdkversion and its value is same what i entered on start.however my point is it does not matter

Importing project gave Unable to resolve target 'android-7'

This app I completed around a year ago (!) but never launched it on the market place. I am trying to open it up in eclipse now to make some small modifications and work on the code a little bit. So I imported it and then found this weird "unable to resolve target" error. It's highlighting every class red in all my 'src' files.
I've looked at a similar question which said to add the line to default.properties file. My project has a project.properties file which has the line:
target=android-7
Any advice how to get this to work? I could always start a new project and just copy all the src files but that would be pretty lame and time-wasting.
One more comment - I'm developing on a new computer and I don't think I have the API level 7. Could that be the problem? I've gone into Window --> Android SDK Manager and the oldest available API it shows is level 8. But level 7 will mean I can target more devices I think so I'd like to go with that.
Thank you for any help.
Well, yes that is your problem. You don't have the API level 7 downloaded. You can right click the project and go properties->android and select another available API. As long as you don't change the min sdk version in your manifest you are still targeting as many devices as before.
<uses-sdk android:minSdkVersion="7"/>
Update
You don't have to do this, but you can get the older APIs on the SDK Archives page
I don't know if there is any official source for the next statement but that is what I found while working. If anybody can complete this with a better answer I would appreciate it very much.
You can compile the code with a newer SDK version as long as you don't use any code not compatible to the previous ones.
Example:
I want my app to be available for API level 7. But i only have API level 15 installed. As long as I keep the minSdkVersion="7" in my Manifest and don't use any resource not available in the previous APIs the app will work just fine on my targeted devices.
For anyone who wants to test their project against an API level that isn't the most recent one, you can just use the SDK Manager to install the old SDK:
In Eclipse (with adt installed):
SDK Manager:
Just check the box of the SDK you want to use to test against your project and click install. You can also remove API's that you aren't using.
Right click on your project then:
Properties -> Android -> Project build target -> Check Android 4.1.2
In your application's manifest.xml file add this tag
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
It's worked for me. Try it.
I resolved this issue by editing my project.properties file
from: target=android-7
to: target=android-19.
I also changed the target sdk version in the manifest file:
android:targetSdkVersion="19".
Yes. I see the same problem when I import the android support v7 project as a library project in my own project,the eclipse says that cannot resolve android16, I find that it's the problem of the eclipse,you can right-click your project which has this problem,and then select properties,the Android pane,there is a Project Build Target pane there,you can see it easily,choose a standard android platform,like Android4.3,not others that start with Google API,I hope that this will help you!
check android:minSdkVersion= in the AndroidManifest.xml
update target=android- in the project.properties if you use Eclipse IDE

Admob Error in Eclipse for android:configChanges

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.
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 !
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.
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.
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!
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.
Easy solution:
Change "project.properties" file to 21
# Project target.
target=android-21
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.

Categories

Resources