当我 运行 我的设备上的应用程序 api 大于 19 时,它给我错误

when I run my app on device having api greater then 19 it gives me error

我正在不同 api 级别测试我的应用程序。它在 minsdk 上运行良好,即 API 19,但是当我 运行 我的应用程序在具有 API > 19 的设备上时,它给我 运行 时间异常。

minSdk =19

TargetSdk =27

如果我的代码有任何错误或错误,那么在任何设备上都不应该 运行。但它在具有 API 19 的设备上正常 运行ning 但在具有 API > 19.

的设备上不正确

完整堆栈跟踪

Process: com.example.lenovo.jdstudio, PID: 5151
                  android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class android.widget.ScrollView
                  Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class android.widget.ScrollView
                  Caused by: java.lang.reflect.InvocationTargetException
                      at java.lang.reflect.Constructor.newInstance0(Native Method)
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                      at android.view.LayoutInflater.createView(LayoutInflater.java:652)
                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:742)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:810)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414)
                      at com.android.internal.app.AlertController.installContent(AlertController.java:236)
                      at android.app.AlertDialog.onCreate(AlertDialog.java:423)
                      at android.app.ProgressDialog.onCreate(ProgressDialog.java:198)
                      at android.app.Dialog.dispatchOnCreate(Dialog.java:392)
                      at android.app.Dialog.show(Dialog.java:296)
                      at com.example.lenovo.jdstudio.SetupActivity.startSetupAccount(SetupActivity.java:95)
                      at com.example.lenovo.jdstudio.SetupActivity.access[=13=]0(SetupActivity.java:31)
                      at com.example.lenovo.jdstudio.SetupActivity.onClick(SetupActivity.java:68)
                      at android.view.View.performClick(View.java:5619)
                      at android.view.View$PerformClick.run(View.java:22295)
                      at android.os.Handler.handleCallback(Handler.java:754)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:163)
                      at android.app.ActivityThread.main(ActivityThread.java:6342)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
                   Caused by: android.content.res.Resources$NotFoundException: Drawable android:drawable/scrollbar_handle_material with resource ID #0x108065d
                   Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-xxhdpi-v4/ic_arrow_back_black_24dp.png from drawable resource ID #0x7f0d0006: .xml extension required
                      at android.content.res.ResourcesImpl.loadComplexColorForCookie(ResourcesImpl.java:963)
                      at android.content.res.ResourcesImpl.loadComplexColorFromName(ResourcesImpl.java:784)
                      at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:863)
                      at android.content.res.Resources.loadColorStateList(Resources.java:1016)
                      at android.content.res.TypedArray.getColorStateList(TypedArray.java:533)
                      at android.graphics.drawable.GradientDrawable.updateStateFromTypedArray(GradientDrawable.java:1268)
                      at android.graphics.drawable.GradientDrawable.applyTheme(GradientDrawable.java:1206)
                      at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:594)
                      at android.content.res.MiuiResourcesImpl.loadDrawable(MiuiResourcesImpl.java:308)
                      at android.content.res.Resources.loadDrawable(Resources.java:872)
                      at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
                      at android.view.View.initializeScrollbarsInternal(View.java:5101)
                      at android.view.View.<init>(View.java:4642)
                      at android.view.ViewGroup.<init>(ViewGroup.java:578)
                      at android.widget.FrameLayout.<init>(FrameLayout.java:92)
                      at android.widget.ScrollView.<init>(ScrollView.java:180)
E/AndroidRuntime:     at android.widget.ScrollView.<init>(ScrollView.java:176)
                      at android.widget.ScrollView.<init>(ScrollView.java:172)
                      at java.lang.reflect.Constructor.newInstance0(Native Method)
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                      at android.view.LayoutInflater.createView(LayoutInflater.java:652)
                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:742)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:810)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414)
                      at com.android.internal.app.AlertController.installContent(AlertController.java:236)
                      at android.app.AlertDialog.onCreate(AlertDialog.java:423)
                      at android.app.ProgressDialog.onCreate(ProgressDialog.java:198)
                      at android.app.Dialog.dispatchOnCreate(Dialog.java:392)
                      at android.app.Dialog.show(Dialog.java:296)
                      at com.example.lenovo.jdstudio.SetupActivity.startSetupAccount(SetupActivity.java:95)
                      at com.example.lenovo.jdstudio.SetupActivity.access[=13=]0(SetupActivity.java:31)
                      at com.example.lenovo.jdstudio.SetupActivity.onClick(SetupActivity.java:68)
                      at android.view.View.performClick(View.java:5619)
                      at android.view.View$PerformClick.run(View.java:22295)
                      at android.os.Handler.handleCallback(Handler.java:754)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:163)
                      at android.app.ActivityThread.main(ActivityThread.java:6342)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

"activity_main.xml"

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lenovo.jdstudio.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include
            layout="@layout/navigation_action"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/main_container">


        </FrameLayout>

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_header"
        app:menu="@menu/navigation_menu">
        <include
            layout="@layout/navigation_header" />
    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

image_list.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="20dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/card_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:src="@mipmap/placeholder4" />

        <TextView
            android:id="@+id/image_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="15dp"
            android:text="Image Title Goes Here"
            android:textSize="16dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/image_resol"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="15dp"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:text="Image Resol Goes here" />
    </LinearLayout>
</android.support.v7.widget.CardView>

fragment_home.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lenovo.jdstudio.HomeFragment">


    <!-- TODO: Update blank fragment layout -->
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/image_list">

    </android.support.v7.widget.RecyclerView>
</RelativeLayout>

在您的 Logcat 上进行优先查看时,由于未找到资源而发生错误。

1) android:drawable/scrollbar_handle_material - 未找到

2) res/mipmap-xxhdpi-v4/ic_arrow_back_black_24dp.png - 未找到

这就是错误的原因 - android.view.InflateException:二进制 XML 文件行

 Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-xxhdpi-v4/ic_arrow_back_black_24dp.png from drawable resource ID #0x7f0d0006: 

Resources$NotFoundException

当找不到请求的资源时,资源 API 会抛出此异常。

Resources$NotFoundException: File res/mipmap-xxhdpi-v4/ic_arrow_back_black_24dp.png

您应该删除 mipmap-xxhdpi-v4 文件夹。应该是mipmap-xxhdpi