【问题标题】:android.view.InflateException: Binary XML file line #11: Binary XML file line #39: Error inflating class support.v4.view.ViewPagerandroid.view.InflateException: Binary XML file line #11: Binary XML file line #39: Error inflating class support.v4.view.ViewPager
【发布时间】:2017-01-08 20:56:46
【问题描述】:

在路径上找不到类“support.v4.view.ViewPager”:DexPathList[[zip file "/data/app/com.example.prakashgurung.atry-1/base.apk"],nativeLibraryDirectories=[ /data/app/com.example.prakashgurung.atry-1/lib/arm, /system/lib, /vendor/lib]]

这是我的 xml 文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.prakashgurung.atry.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

        <android.support.design.widget.TabLayout
            android:id="@+id/mtab_ID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />

    <android:support.v4.view.ViewPager
        android:id="@+id/mViewpager_ID"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

  • 您是否已将 V4 支持 Core UI 库添加到您的 build.gradle 中? compile 'com.android.support:support-core-ui:25.1.0'
  • 我刚刚添加了这个,但我仍然收到同样的错误。
  • 好的,只需检查几件事。您是否通过 SDK 管理器下载了Android Support Library?将其添加到 build.gradle 后,您是否进行了 gradle 同步?您是否在再次测试之前清理了您的项目?
  • 好吧,让我来做
  • 我刚刚做了你提到的所有事情,目前没有运气。

标签: java android xml


【解决方案1】:

找到了。这是一个错字。将&lt;android:support.v4.view.ViewPager 更改为&lt;android.support.v4.view.ViewPager。 (注意android后面的冒号,应该是点)。

【讨论】:

  • 谢谢,明白了
猜你喜欢
  • 2013-06-25
  • 1970-01-01
  • 2020-06-27
  • 1970-01-01
  • 2016-11-03
  • 2017-06-05
  • 2017-01-13
  • 1970-01-01
  • 2016-07-11
相关资源
最近更新 更多