【问题标题】:android - google play services ads - The following classes could not be instantiated: com.google.android.gms.ads.AdViewandroid - 谷歌播放服务广告 - 无法实例化以下类:com.google.android.gms.ads.AdView
【发布时间】:2014-08-15 18:38:07
【问题描述】:

我刚刚清理了安装的 Android 开发工具 (ADT),但无法让 Google Play 服务正常工作;更具体地说,我无法通过布局预览来实例化 adView BANNER。

将最新的 GPS 库导入我的工作区(从 sdk/extras/Google/google-play-services 复制到工作区)

右键项目>属性>android选项卡>将GPS库添加到项目

在我的项目清单中添加了以下内容:

外面<application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

内部&lt;application&gt;

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

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

Minium sdk 设置为"9"

目标"21"

在我的布局文件中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >


<com.google.android.gms.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     ads:adUnitId="my ad id as stated on apps.admob.com"
                     ads:adSize="BANNER"/>

在图形布局窗格中,出现错误

The following classes could not be instantiated:
- com.google.android.gms.ads.AdView

我是不是忘记了什么?我在某处犯了错误吗?任何人都对如何解决此问题有任何想法>

谢谢!

【问题讨论】:

  • 另请注意:在我的安卓设备上运行应用程序时,广告可以正常工作;只有预览不能正常工作

标签: android eclipse google-play-services


【解决方案1】:

这对我来说是一个临时的解决方法。我将 Google Play Services SDK 的版本从 5.x 降级回 4.x。我将 Intellij Community 13.x 与 Gradle 一起使用,因此我的依赖项部分现在如下所示:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.0.0'
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'com.google.android.gms:play-services:4.+'
}

同样,只是暂时的,让我可以完成构建我的 XML 布局文件。当我进入最终测试阶段时,我计划升级到最新版本 5.x。我已向 Google AdMob 广告开发者论坛提交了有关此问题的问题,希望能引起人们的注意。我还没有找到为此特定 SDK 提交错误报告的方法,但我仍在寻找。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    相关资源
    最近更新 更多