【问题标题】:The following classes could not be instantiated: - com.google.ads.AdView无法实例化以下类:- com.google.ads.AdView
【发布时间】:2014-04-09 11:30:00
【问题描述】:

我无法运行我的应用程序...这是activitymain_xml 中的问题。有人可以帮助我吗? 那是layout activity

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context="com.denisprojects.shoppinglist.MainActivity"
tools:ignore="MergeRootFrame" >



   <Button
    android:id="@+id/button2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="80dp"
    android:layout_height="50dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="@drawable/add" />
<com.google.ads.AdView
    android:id="@+id/adsView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/button2"
    ads:adUnitId="ca-app-pub-5426545253667840/7625762411"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true" />
</RelativeLayout>

我已经看到了其他任务,但我仍然无法运行我的应用程序。对不起我的英语,希望你能理解。

【问题讨论】:

  • 确保在项目的构建路径中添加了库文件。
  • 我添加它......我在 AndroidManifest 中添加了这些行......我真的不明白问题出在哪里......也许有人知道

标签: java android


【解决方案1】:

确保您还在 AndroidManifest 中声明了 AdActivity

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

【讨论】:

  • 是的..我导入了 lib admodsdk 6.4 和 google play 并将其添加到构建路径....仍然得到错误。
  • 无法实例化以下类:- com.google.ads.AdView
【解决方案2】:

您似乎忘记在项目的构建路径中添加谷歌广告库文件。

【讨论】:

    猜你喜欢
    • 2017-03-30
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    相关资源
    最近更新 更多