android admob 集成问题 - 不允许使用字符串类型

android admob integration issue - string types not allowed(android admob 集成问题 - 不允许使用字符串类型)

本文介绍了android admob 集成问题 - 不允许使用字符串类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试集成 admob.我遵循here 的文档规则,并且看到了 几个 相关 页面a>,但我似乎仍然做错了什么.
我正在使用 GoogleAdMobAdsSdk-6.1.0.jar,以及 android sdk 版本 13 (Android 3.2).

I'm trying to integrate admob for the first time. I followed the documentation rules here, and I've seen several related pages, but I still seem to be doing something wrong.
I'm using GoogleAdMobAdsSdk-6.1.0.jar, as well as android sdk version 13 (Android 3.2).

我包含了一些我发现需要从各种来源获得的东西.

I included several things that I've found are required from various sources.

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="13" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScre‌​enSize"  />

在我的 AndroidManifest.xml 中.

in my AndroidManifest.xml.

我包括

target=android-13

在我的 project.properties 中.

in my project.properties.

以上配置无法编译.我在 Eclipse(版本:4.2.0)中收到错误,说明如下:

The above configuration does not compile. I get an error in eclipse (Version: 4.2.0) stating the following:

error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScre‌​enSize'

如果我把它改成旧样式

android:configChanges="keyboard|keyboardHidden|orientation"

项目编译得很好,但是当我开始我的活动时,我遇到了以下问题:

the project compiles just fine, but when I get to my activity I have the following problem:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/Aqua"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/adLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </LinearLayout>

</LinearLayout>

我的活动中的代码如下所示:

The code in my activity looks like this:

public class TutorialActivity extends Activity {

    private static final String PUBLISHER_ID = "blah"; //omitted
    private AdView adView;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.tutorial_layout);
        AdRequest request = new AdRequest();
        request.addTestDevice("what i believe is my device id");

        adView = new AdView(this, AdSize.BANNER, PUBLISHER_ID);

        LinearLayout layout = (LinearLayout) findViewById(R.id.adLayout);
        layout.addView(adView);
        adView.loadAd(request);
    }

    @Override
    public void onDestroy() {
        if (adView != null) {
            adView.destroy();
        }
        super.onDestroy();
    }

}

当我运行此代码并导航到我的活动时,我看到了屏幕顶部的广告框,正如我所期望的那样,其中包含以下文本:您必须在 AndroidManifest.xml 中使用 configChanges 声明 AdActivity.

When I run this code and navigate to my activity, I see what looks to be an ad box at the top of the screen as I would expect, and inside it is the following text: You must have AdActivity declared in AndroidManifest.xml with configChanges.

我是一个困惑的人.在将其发布到谷歌应用商店之前,这是我最不想包含在我的应用中的东西,非常感谢任何建议或帮助.如果我遗漏了任何内容,我深表歉意.

I am one confused individual. This is the very last thing I'd like to include in my app before releasing it to the google app store, and any advice or help is much appreciated. I apologize if I've left anything out.

推荐答案

我也遇到了同样的问题.我会告诉你我做了什么.

I had the same problem. I will tell you what I did.

在eclipse中右键项目文件夹

right click on the project folder in eclipse

  • -属性
  • -选择安卓
  • -选择固件 3.2 或更高版本

然后在清单中使用它

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"

就是这样

这篇关于android admob 集成问题 - 不允许使用字符串类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:android admob 集成问题 - 不允许使用字符串类型

基础教程推荐