gpt4 book ai didi

android - 二进制 XML 文件行 #6 : Error inflating class com. google.ads.AdView

转载 作者:太空狗 更新时间:2023-10-29 12:41:50 27 4
gpt4 key购买 nike

我的 logcat 在将 admob 添加到我的项目时显示此类错误。我尝试手动添加 sdk jar 文件但仍然不起作用。我的 libs 文件夹包含 jars-google-play-services 和 android-support-v4.i 引用了其他有相同错误的帖子,但对我没有任何帮助。

日志

07-02 00:26:42.082: E/AndroidRuntime(26811): FATAL EXCEPTION: main
07-02 00:26:42.082: E/AndroidRuntime(26811): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xmlpullparserproject/com.example.xmlpullparserproject.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.ads.AdView
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread.access$600(ActivityThread.java:149)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.os.Looper.loop(Looper.java:153)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread.main(ActivityThread.java:5086)
07-02 00:26:42.082: E/AndroidRuntime(26811): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 00:26:42.082: E/AndroidRuntime(26811): at java.lang.reflect.Method.invoke(Method.java:511)
07-02 00:26:42.082: E/AndroidRuntime(26811): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
07-02 00:26:42.082: E/AndroidRuntime(26811): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
07-02 00:26:42.082: E/AndroidRuntime(26811): at dalvik.system.NativeStart.main(Native Method)
07-02 00:26:42.082: E/AndroidRuntime(26811): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.ads.AdView
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-02 00:26:42.082: E/AndroidRuntime(26811): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:258)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.Activity.setContentView(Activity.java:1867)
07-02 00:26:42.082: E/AndroidRuntime(26811): at com.example.xmlpullparserproject.MainActivity.onCreate(MainActivity.java:31)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.Activity.performCreate(Activity.java:5020)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
07-02 00:26:42.082: E/AndroidRuntime(26811): ... 11 more
07-02 00:26:42.082: E/AndroidRuntime(26811): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView
07-02 00:26:42.082: E/AndroidRuntime(26811): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-02 00:26:42.082: E/AndroidRuntime(26811): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-02 00:26:42.082: E/AndroidRuntime(26811): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
07-02 00:26:42.082: E/AndroidRuntime(26811): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
07-02 00:26:42.082: E/AndroidRuntime(26811): ... 21 more

xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xyz"
ads:adSize="BANNER"

/>
<ListView
android:id="@+id/lv_countries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity" />

</RelativeLayout>

主要 Activity

setContentView(R.layout.activity_main);

AdView adView = (AdView)this.findViewById(R.id.adView);

AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) //
.addTestDevice("3a2d1115ab64e3") //
.build() ;
adView.loadAd(adRequest);

最佳答案

广告 xml 命名空间错误:

在 GoogleAdMobAdsSdk-6.4.1.jar 或更早版本中,您使用:

<com.google.ads.AdView 

命名空间:

 xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads"

在通过播放服务库的 Google admob 中,您使用:

<com.google.android.gms.ads.AdView

命名空间:

 xmlns:ads="http://schemas.android.com/apk/res-auto

关于android - 二进制 XML 文件行 #6 : Error inflating class com. google.ads.AdView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24518201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com