Google Admob Integration Errors - android

I am working on an app for Android 2.2 Platform, wanted to integrate admob into it, StackOverflow I set up an account downloaded the latest admob SDK and created an ad Layout in XML followed the instructions mentioned in docs. I have set the target in project properties to 1.4 and set the min SDK to 8. Now the error occurs when I configure
<activity Android:name="com.Google.ads.AdActivity" Android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
The String
keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize
wont compile for Android 2.2 it throws errors. However if I compile without these screenSize|smallestScreenSize, it compiles but the ad area in the app shows an error saying You must have AdActivity declared in AndroidManifest with configChanges
Can you guys suggest a solution, any help with this problem is appreciated.

The Google AdMob SDK v4.3.1 requires the additional config changes for optimization on tablets that are running apps with Google AdMob Ads. The configChanges screenSize and smallestScreenSize were not introduced until android-13, so therefore the Google AdMob SDK requires you to COMPILE against Android 3.2 or greater.
You can still make your app run on Android 2.2 devices/emulators by setting the minSdkVersion in your manifest:
<uses-sdk android:minSdkVersion="8" />

set target in project.properties to android-13 (Android v3.2)
not in manifest! (this is that I misunderstood)

Related

GooglePlay services integration with froyo fails in gradle

I am on Android Studio and I have followed the instructions on Google here.
I have downloaded via the SDK Manager the google repository, google play services for froyo and not for froyo.
My gradle
// this works
// compile 'com.google.android.gms:play-services:4.1.32'
// this doesn't
// compile 'com.google.android.gms:play-services:3.2.65'
(I uncomment one or the other, not both at the same time)
My manifest
<application
...
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
Any idea ?
iirc, Google doesn't actually provide an aar for froyo play services. I think you have to manually import ANDROID_SDK\extras\google\google_play_services_froyo\libproject\google-play-ser‌​vices_lib from your SDK directory as a module, then compile that module as a dependency in gradle.
The link you referenced that you were following mentions nothing about froyo or gradle, are you sure you're following the right tutorial? This seems to indicate my answer above if correct: http://developer.android.com/google/play-services/setup.html
The workaround is from Nov 2013 to hardcode the gms version in the manifest
https://code.google.com/p/android/issues/detail?id=61675
"com.google.android.gms.ads.AdActivity" does not exist in version 3.2.65 (Froyo) of Google Play Services. Google seems to have stopped updating the library for google_play_services_froyo.
a
you will need to use google_play_services (current version is 4.3.23) to use AdView and AdRequest, but that version requires a minsdk of 9 (Gingerbread).
I am facing the same problem as you, and I have a small percentage of active users still using Froyo (mostly in third world countries). For now I intend to split my apps to different flavors- one of which will use the Admob standalone SDK until they stop serving ads (and it'll remain ad free for my Froyo users).

Admob error android:configChanges in Eclipse and Device

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">"
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. But there is no ads displayed.
I'm using GoogleAdMobAdsSDK-4.3.1.
If i set project.properties target-13.my android 2.3 device does not run the app..But my device run so many app that having ads are displayed..
Please Help me..!!!
you need do this:
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).
Check out this blog post. You need to set android-13 for 4.3.1 to compile, but you can use
<uses-sdk android:minSdkVersion="9"/>
or any version down to 3, and your app will then run on your 2.3 device.

Admob implementation Error

I got a Problem with implementing Admob into an App.
This is my main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
and this is my Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ollidiemaus.testmob"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".TestAdmobActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
And finaly this is my Activity:
public class TestAdmobActivity extends Activity {
private AdView adView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
adView = new AdView(this, AdSize.BANNER, "a14ead58dc2a456");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="#+id/mainLayout"
LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout1);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());}
#Override
public void onDestroy() {
adView.destroy();
super.onDestroy();
}}
Now when i'll start the app in the AdView is an error called: "you must have AdActivity declared in AndroidManifest.xml with configChanges."
I used Android 4.0 so above 3.2 but it is not working.
I hope anyone could help me.
I had exactly the same problem with getting the "you must have AdActivity declared in AndroidManifest.xml with configChanges." error message after integrating the latest AdMob SDK. Even though I have found this and the other two related discussions (see links at the bottom of this article) at StackOverflow, they didn't help me to solve the issue, as -- for me -- they did not differentiate clear enough between the targetSdkVersion attribute in the manifest and the build target. This answer describes what solved the issue for me and what caused trouble.
Solution
The easiest part at first: you are missing a few flags in the configChanges attribute of the definition of the AdActivity in your AndroidManifest.xml. As shown in the AdMob SDK Docs the definition needs to look like this:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
The second -- and more complicated part -- is related to the SDK target: The only solution that really seems to work is to use the SDK manager to install the SDK for at least Android 3.2 (API level 13). After you have installed this SDK version you need to configure your IDE to build your project using this SDK. The exact setting depends on the IDE you are using. In my case it is IntelliJ IDEA and there you will find the option in the project settings on the Project page below the headline Project SDK.
You should also adjust the target property in your project's project.properties. This is at least important if you are building your release using ANT. The line should look like this:
target=android-13
The configuration above alone does the trick. There are no changes required to the <uses-sdk> element in the AndroidManifest. Read the pitfalls below to learn why this may cause trouble.
Explanation
The build target and the <uses-sdk> elements have completely different scopes.
The build target is evaluated only at build time by your build tools to determine which version of the SDK tools on your system should be used to build your app. The newer the SDK the more API features does it know. Out of whatever reason Google forces us to specify some configChanges which aren't available before API level 13 and so we need to build our app using at least the SDK tools 13 because a previous version of the SDK tools does not know these new configChanges and will report an error. At runtime the build target does not have any meaning and Android will ignore all elements (e.g. in configChanges) which it does not know.
The targetSdkVersion element specified on the <uses-sdk> element in the android manifest in contrast is only evaluated at run time -- not at compile time. In fact you can specify any value you want here without the compiler changing anything or bringing up an error message. This is why changing this attribute does not help us to solve our AdMob problem. On the other hand at runtime the attribute may be evaluated by android to support some compatibility features for apps which have been build for older android versions. See the pitfalls section below to see a topic which caused trouble for me.
Pitfalls
Do not change set targetSdkVersion to a higher version if you are not able to test your app on this android version: Because I have misunderstood the existing answers regarding this admob topic I have also set the android:targetSdkVersion attribute of the <uses-sdk> element to API level 13 in my app which caused a fatal side effect: As Android 3 thought my app would natively support honeycomb, it did no longer show the menu button in the soft button bar at the bottom border and as my app hides the native title bar to show it's own implementation the user did not have any possibility to access the menu any more on honeycomb. So for me leaving the targetSdkVersion at level 10 helped to bring back the menu button and worked fine.
Handling backward compatibility to older APIs which may be lost in SDK tools 13: OK, so I have set my build process to use the SDK tools 13 and my targetSdkVersion to 10 and everything should be fine, right? Unfortunately not! The reason is, that my app is compatible downwards to Android 1.5 (API level 3) as this still makes up about 5% of my users. Unfortunately after setting the build target to 13 some parts of my code did not compile any more as they referenced deprecated methods which were supported until SDK tools 10 but no longer starting with SDK tools 11 (e.g. Service.setForeground).
The basics how to handle backwards compatibility are described here -- but this article does not describe how to call deprecated methods which are no longer available as they will cause a compiler error. I solved this by creating a new library project used by my app. For this library project I have set the build target back to 10 which will cause it to be compiled using the SDK tools 10 which still know about the android deprecated API I am using. My app then calls helper methods from this compatibility library and so I can compile my app with a newer target SDK.
Related Topics
Here the list of the other related discussions I have found:
AdMob can't display ads because of configChanges
AdMob SDK 4.3.1 - I can't display banner
My solution to a similar case was to use
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="11" />
or just use android:targetSdkVersion= under 13
You also need to set the following permissions in your AndroidManifest.xml.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Then admob can assess the internet and also not show the ad when it has no internet connectivity.
Have you also set your build target to be higher than Android 3.2, i.e. in default.properties set target higher than android-13? Also make sure that you're using the latest version of the SDK.
PS! Don't expose your device ID to the public.
As you can see here, very few phones have Android versions of 3.x.x or higher installed
http://developer.android.com/resources/dashboard/platform-versions.html
Why would anybody want to compile their app to something few phones can handle? Either I am misunderstanding something or I will need to find some other ad company that doesn't require a newer Android version.
Above error occurs when you use the library GoogleAdMobAdsSdk-4.3.1.jar.
I've been that error and I've found this demo from Google.
I've replaced lib 4.3.1 by 4.0.3 in this demo and it runs OK.
if you use AndroidStudio and Gradle, you must also update the build.gradle file like this:
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 3
targetSdkVersion 17
}
...

Admob with Android: unable to parse android:configChanges in manifest

I am trying to add ads to my Android app using Admob, but have hit a brick wall. Admob says it requires the following from logcat
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
However, the Android SDK in Eclipse on Ubuntu fails to be able to parse the following,
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
When I go to the activity and select the attribute in the manifest, the last three items show 'Unrecognized flag'.
I want to add ads in on Android 1.6 (API level 4), but these attributes don't exist until API levels in the teens. How do I reconcile this?
The AdMob SDK v4.3.1 was released late last night. The SDK requires these new configChanges for tablet optimization, but these configChanges are only available in Honeycomb and above.
You will need to download Android SDK Version 3.2 or above, and then set target=13 or above in your project.properties file to compile against the new SDK version. It will still support Android 1.5 devices and above, and that can be controlled by the minSdkVersion in your manifest.

com.google.android.maps not available

I'm new to Android and I'm using IntelliJ to develop. I'm going through various tutorials, etc and now I'm trying to run/compile Wrox project that uses com.google.android.maps
IntelliJ wouldn't compile, it complains that this package does not exist.
How do I add it to project? I have everything downloaded in ADT. I was able to run all other projects no problem. What should I look for?
You need to target the Google APIs instead of Android - in IntelliJ, File-Project Structure SDKs and select Google APIs in Build Target.
Are you targetting the correct Android-jar? You'd want the one with the Google API:s for maps to work. Also make sure you're including the correct permission in your manifest.
And after installing the google api and setting up a project based on the correct api, don't forget the uses-libary tag in the manifest:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />

Categories

Resources