gpt4 book ai didi

android - 找不到文件 res/drawable/abc_ic_ab_back_material.xml

转载 作者:行者123 更新时间:2023-11-29 01:17:20 25 4
gpt4 key购买 nike

我在 API 级别 19 (Kit Kat) 上的应用程序出现错误。我实现了 android 支持库 24.0.0 并开始我的 Activity 并收到以下错误:

Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0

在堆栈跟踪的更下方有类似的东西

java.lang.RuntimeException: Unable to start activity ComponentInfo{ironicdev.android.openleaf/ironicdev.android.openleaf.ui.activity.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.widget.Toolbar

然后

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016

(我不想发布完整的堆栈跟踪)。

我在谷歌上找到了一些解决方案,比如在我的 gradle 文件中设置“vectorDrawables.useSupportLibrary = true”。但这没有帮助。我在菜单栏中选择“清理项目”,但没有。

我还删除了所有矢量 xml 文件并将其替换为 png 文件。但是错误仍然存​​在。

如果我从 API 21 及更高版本开始,一切都很好。

我现在该怎么办?

编辑:这是我来自 MainActivty 的 xml 代码(抛出错误的地方)

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"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />

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

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.activity.MainActivity"
tools:showIn="@layout/app_bar_main">

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

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

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

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="@string/tv_newest_entries" />

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_newest_entries"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

extended_app_bar_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/tv_simple_search"
android:textColor="@color/colorFontInverted"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:visibility="gone"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">

<EditText
android:id="@+id/et_simple_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="@android:color/white"
android:textColor="@color/colorFontInverted"
android:hint="@string/hint_simple_search" />

<ImageButton
android:id="@+id/btn_simple_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@android:color/transparent"
android:src="@drawable/ic_magnify_white_24dp" />
</LinearLayout>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
style="@style/Widget.AppCompat.Button.Colored"
android:theme="@style/Accent.Button"
android:text="@string/btn_advanced_search"/>
</LinearLayout>

content_dashboard_diagram.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="220dp"
android:orientation="vertical">

<com.github.mikephil.charting.charts.PieChart
android:layout_margin="12dp"
android:id="@+id/pie_categories"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

最佳答案

我前几天也遇到了这个问题。

确保你所有的 Activity 主题都是从 Theme.AppCompat 扩展而来的,这应该是固定的

我在官方跟踪器上创建了一个问题来解释这个问题:https://code.google.com/p/android/issues/detail?id=219724

关于android - 找不到文件 res/drawable/abc_ic_ab_back_material.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38774831/

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