English 中文(简体)
吸烟
原标题:Admob implementation Error

我提出一个问题,将Admob落实为上诉。

这是我的主轴:

<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>

这是我的万物:

<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>

最后,我的活动是:

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();
}}

现在,在AdView中,一开始,就是一个错误,即:“必须具有在Manifest.xml与ConigChanges宣布的代人行为”。

I used Android 4.0 so above 3.2 but it is not working. I hope anyone could help me.

最佳回答

我在把最新的AdMob SDK.合并后,把“你必须拥有在Andreifest.xml中宣布的代谢”错误信息混为一谈。 尽管我发现这一点以及在StackOverflow举行的另外两次相关讨论(见本条款底线上的联系),但这些讨论并没有帮助我解决这个问题,因为——对我来说——他们并没有在宣言和建筑目标中明确区别。 这一答案描述了我所要解决的问题和造成麻烦的问题。

Solution

首先最容易的部分:在<代码>上,你没有几条旗帜。 如AdMob SDK Docs/a>。 定义需要考虑这一点:

<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.

您还应在项目<代码>中调整target property。 如果你利用《公约》建立释放你的工作,这至少很重要。 这行文如下:

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

该建筑指标和<编码>与设计;用途-sdk>内容完全不同。

<build Target is evaluation only at building time by You Building instruments to identifying the which edition of the SDK instruments on You system should be used to building their app. SDK的新特征是它知道的。 无论出于何种原因,谷歌迫使我们具体指明一些<代码>configChanges。 早在第13级之前就已经提供,因此我们需要至少使用SDK工具13来建立我们的评估,因为以前的SDK工具版本并不了解这些新的<代码>configChanges,并将报告错误。 如今,建筑目标没有任何意义,安伯将忽视它所不知道的所有要素(例如:<条码>栏目<>)。

<targetSdkVersion elements specified on the <uses-sdk> elements in the android show in Comparative is only<>em> http://www.em>not。 事实上,如果汇编者不改变任何内容或发出错误信息,你可以在此明确你想要的任何价值。 因此,改变这一特性无助于我们解决我们的阿杜卜问题。 另一方面,在操作阶段,甲状腺可以评估特性,支持为旧的和roid的仪器建造一些相容性。 下面的陷阱部分看了一个给我造成麻烦的议题。

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).

如何处理后向兼容性的基本内容见:,但该条并未说明如何使用已不复存在的折旧方法,因为它们会造成汇编错误。 我通过建立一个由我评估使用的新的图书馆项目来解决这一问题。 就这一图书馆项目而言,我已将建筑目标重新设定为10个,这将使建筑目标能够利用仍然知道我正在使用的甲状腺衰竭的10种SDK工具加以汇编。 然后,我用这个兼容图书馆的助手方法,因此,我可以把我的意见与更新的目标SDK汇编在一起。


Related Topics

我在此看到其他相关讨论清单:

问题回答

我对类似情况的解决办法是使用

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="11" />

或公正的使用和roid:目标 SdkVersion=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.

你们是否也把建筑目标设定在比安特3.2高的水平上,即违约。 设定的目标比roid-13高? 还确保你重新使用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

rel=“nofollow” http://developer.android.com/resources/dash板/platform-versions.html

为什么有人想把他们的用电汇到少数能够处理的电话? 要么我误解,要么我需要找到其他一些需要新版的超公司。

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.

如果你使用安乐素和格拉斯,你也必须更新建筑。 梯度档案类似:

android {
    compileSdkVersion 17
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 3
        targetSdkVersion 17
    }
...




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签