我的项目名为" fantacalcio2"我想添加一个admob横幅。 应用程序工作正常,但当我添加xml横幅我有这个异常和应用程序刚开始崩溃。我该如何解决这个问题?这是我的日志:
09-13 18:54:49.813: E/AndroidRuntime(19565): FATAL EXCEPTION: main
09-13 18:54:49.813: E/AndroidRuntime(19565): Process: com.falc1.fantacalcio2, PID: 19565
09-13 18:54:49.813: E/AndroidRuntime(19565): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.falc1.fantacalcio2/com.falc1.fantacalcio2.MainActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class com.google.ads.AdView
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.os.Handler.dispatchMessage(Handler.java:102)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.os.Looper.loop(Looper.java:136)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread.main(ActivityThread.java:5001)
09-13 18:54:49.813: E/AndroidRuntime(19565): at java.lang.reflect.Method.invokeNative(Native Method)
09-13 18:54:49.813: E/AndroidRuntime(19565): at java.lang.reflect.Method.invoke(Method.java:515)
09-13 18:54:49.813: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
09-13 18:54:49.813: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
09-13 18:54:49.813: E/AndroidRuntime(19565): at dalvik.system.NativeStart.main(Native Method)
09-13 18:54:49.813: E/AndroidRuntime(19565): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.google.ads.AdView
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-13 18:54:49.813: E/AndroidRuntime(19565): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.Activity.setContentView(Activity.java:1929)
09-13 18:54:49.813: E/AndroidRuntime(19565): at com.falc1.fantacalcio2.MainActivity.onCreate(MainActivity.java:68)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.Activity.performCreate(Activity.java:5231)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
09-13 18:54:49.813: E/AndroidRuntime(19565): ... 11 more
09-13 18:54:49.813: E/AndroidRuntime(19565): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: DexPathList[[zip file "/data/app/com.falc1.fantacalcio2-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.falc1.fantacalcio2-1, /vendor/lib, /system/lib]]
09-13 18:54:49.813: E/AndroidRuntime(19565): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-13 18:54:49.813: E/AndroidRuntime(19565): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
09-13 18:54:49.813: E/AndroidRuntime(19565): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
09-13 18:54:49.813: E/AndroidRuntime(19565): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
这是xml布局:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/relative_layout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="adunit"
android:gravity="bottom" />
</RelativeLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:0)
这意味着您尚未在自己的APK中添加Admob课程。
另请注意,您正在尝试使用旧的Admob类(6.4.1及更早版本)。您应该真正使用Google Play服务中的新课程。
请参阅https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner