简体   繁体   English

使adMob在android较旧的版本上运行

[英]get adMob running for android older versions

I read a lot of documentation of adMob working on Android but I am still confused! 我阅读了许多关于Android上的adMob的文档,但我仍然感到困惑! adMob works only from 3.2 version? adMob仅适用于3.2版本? If yes, my app supports 2.2 (api 8), so if I change app properties to api 13 in order to allow adMob, does it means that my app will needs at least 3.2 devices?? 如果是,我的应用程序支持2.2(api 8),因此如果我将应用程序属性更改为api 13以允许adMob,是否意味着我的应用程序至少需要3.2台设备? If yes, how could I filter that if device <3.2, app will work without adMob, and if >=3.2, will integrate adMob?? 如果是,我该如何过滤,如果设备<3.2,则应用程序无需adMob就可以运行,而如果> = 3.2,则可以集成adMob? Thank you 谢谢

some people are confused about the minsdk, target sdk and the whole build target thing. 有些人对minsdk,目标sdk和整个构建目标感到困惑。 Lets say you want to develop an app that works with ICS and also older versions, like SDK 10. 假设您想开发一个可与ICS以及旧版本(例如SDK 10)一起使用的应用程序。

Your Manifest has to contain this: 您的清单必须包含以下内容:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15" />

Then add the newest AdMob xxxx.jar file to the buildpath, don't add any old versions. 然后,将最新的AdMob xxxx.jar文件添加到构建路径中, 不要添加任何旧版本。

Add the AdMob activity 添加AdMob活动

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

Now it is time to setup the properties: 现在是时候设置属性了:

in project.properties set: 在project.properties中设置:

    # Project target.
target=android-15

Right click your project 右键单击您的项目

Click Android , On the right side you will see a list of available targets. 点击Android ,在右侧,您会看到可用目标的列表。 In this case I selected 4.0.3 (15). 在这种情况下,我选择了4.0.3(15)。

Your application will now work with Android 10 - Android 15. I tested this with a Nexus Ace (2.2), htc wildfire S (2.3.3) and a Galaxy Nexus (ICS) - worked fine so far. 您的应用程序现在可以在Android 10-Android 15上运行。到目前为止,我已经使用Nexus Ace(2.2),htc wildfire S(2.3.3)和Galaxy Nexus(ICS)进行了测试。

the API 13 requirement is just for the build process. API 13要求仅用于构建过程。

it's not the min sdk requirement, that's separate. 这不是最低SDK要求,这是分开的。 I compile apps with AdMob and the ICS SDK version (API 16 I think?) but they still run in Donut, even with ads. 我使用AdMob和ICS SDK版本(我认为是API 16)来编译应用程序,但即使在带有广告的情况下,它们仍可以在Donut中运行。

Set your application target to 3.2 and in order to enable older devices to still run your app, go to your AndroidManifest.xml file and use: 将您的应用程序目标设置为3.2,并且为了使较旧的设备仍能运行您的应用程序,请转到您的AndroidManifest.xml文件并使用:

<uses-sdk android:minSdkVersion="8" />

This will enable AdMob on all your desired devices. 这将在所有所需的设备上启用AdMob。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM