无法将admob代码添加到我的应用程序中?

时间:2013-04-17 08:12:47

标签: java android

我正在尝试使用本教程

在我的Android应用中集成AdMob广告

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> 

这是catlog

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

1 个答案:

答案 0 :(得分:1)

我解决了它必须将admob jar文件添加到libs

以外的项目referenced libraries文件夹中