0

我正在尝试使用本教程将 AdMob 广告集成到我的 Android 应用中

http://www.wikihow.com/Add-Advertisements-to-Your-Android-Applications-Using-Admob

但问题是在完成每一步之后我的应用程序在启动时关闭

为什么?

布局xml文件

<?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads" 
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_gravity="bottom"
       android:background="@drawable/background" >


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

这是目录

04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2070)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread.access$600(ActivityThread.java:137)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.os.Looper.loop(Looper.java:213)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread.main(ActivityThread.java:4786)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at java.lang.reflect.Method.invokeNative(Native Method)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at java.lang.reflect.Method.invoke(Method.java:511)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at dalvik.system.NativeStart.main(Native Method)
04-17 11:10:46.018: E/AndroidRuntime(19320): Caused by: android.view.InflateException: Binary XML file line #76: Error inflating class com.google.ads.AdView
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.Activity.setContentView(Activity.java:1867)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at net.alien.relaxhdfree.Main.onCreate(Main.java:12)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.Activity.performCreate(Activity.java:5008)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
04-17 11:10:46.018: E/AndroidRuntime(19320):    ... 11 more
04-17 11:10:46.018: E/AndroidRuntime(19320): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView
04-17 11:10:46.018: E/AndroidRuntime(19320):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
04-17 11:10:46.018: E/AndroidRuntime(19320):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
04-17 11:10:46.018: E/AndroidRuntime(19320):    ... 23 more
4

1 回答 1

1

我解决了 admob jar 文件必须添加到项目libs文件夹中referenced libraries

于 2013-04-17T08:19:50.927 回答