将AdMob AdView与Listview配合使用

时间:2014-05-16 17:41:09

标签: android android-listview

请原谅我的无知,我是编程的新手。不确定如何将AdMob AdView与ListView集成到我的应用中。当我尝试使用此代码运行它时,应用程序会一直崩溃:

这是我的主要活动xml:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:background = "@drawable/ocean_three"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.ads.AdView android:id="@+id/adView"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 ads:adUnitId="123456789"
                 ads:adSize="BANNER"
                 ads:loadAdOnCreate="true"/>

<ListView
  android:id="@+id/list"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:divider="@null"
  android:dividerHeight="0dp"
  android:listSelector="@drawable/list_selector">
</ListView>


</LinearLayout>

这里是logcat:

05-15 21:17:03.154: D/AndroidRuntime(21810): Shutting down VM
05-15 21:17:03.154: W/dalvikvm(21810): threadid=1: thread exiting with uncaught exception (group=0x4178b898)
05-15 21:17:03.184: E/AndroidRuntime(21810): FATAL EXCEPTION: main
05-15 21:17:03.184: E/AndroidRuntime(21810): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.official.thecevicheapp/com.official.thecevicheapp.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.ads.AdView
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread.access$700(ActivityThread.java:165)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.os.Looper.loop(Looper.java:137)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread.main(ActivityThread.java:5455)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at java.lang.reflect.Method.invokeNative(Native Method)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at java.lang.reflect.Method.invoke(Method.java:525)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at dalvik.system.NativeStart.main(Native Method)
05-15 21:17:03.184: E/AndroidRuntime(21810): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.ads.AdView
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.Activity.setContentView(Activity.java:1956)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at com.official.thecevicheapp.MainActivity.onCreate(MainActivity.java:57)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.Activity.performCreate(Activity.java:5372)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
05-15 21:17:03.184: E/AndroidRuntime(21810):    ... 11 more
05-15 21:17:03.184: E/AndroidRuntime(21810): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: /data/app/com.official.thecevicheapp-1.apk
05-15 21:17:03.184: E/AndroidRuntime(21810):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.createView(LayoutInflater.java:565)
05-15 21:17:03.184: E/AndroidRuntime(21810):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
05-15 21:17:03.184: E/AndroidRuntime(21810):    ... 21 more

0 个答案:

没有答案
相关问题