繁体   English   中英

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

[英]android admob integration issue - string types not allowed

我正试图第一次整合admob。 我跟着文档的规则在这里 ,我已经看到一些 相关的 页面 ,但我仍然似乎是做错了什么。
我正在使用GoogleAdMobAdsSdk-6.1.0.jar,以及android sdk版本13(Android 3.2)。

我从各种来源中找到了我需要的几件东西。

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

包括我

target=android-13

在我的project.properties中。

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

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

如果我把它改成旧式

android:configChanges="keyboard|keyboardHidden|orientation"

该项目编译得很好,但是当我进入我的活动时,我遇到以下问题:

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

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

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 。

我是一个困惑的人。 这是我在将应用程序发布到谷歌应用程序商店之前在我的应用程序中包含的最后一件事,并且非常感谢任何建议或帮助。 如果我遗漏了任何东西,我道歉。

我有同样的问题。 我会告诉你我做了什么。

右键单击eclipse中的项目文件夹

  • -Properties
  • - 选择android
  • - 选择固件3.2或更高版本

然后在清单中使用它

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

就这样

暂无
暂无

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

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