android.content.res.Resources $ NotFoundException为ic_sync_black_24dp.xml [英] android.content.res.Resources$NotFoundException for ic_sync_black_24dp.xml

查看:387
本文介绍了android.content.res.Resources $ NotFoundException为ic_sync_black_24dp.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这个奋斗了一个多星期,因为我想它要的东西与我的环境,但我不能缩小它。

I've struggled with this for over a week, because I figure it has to be something with my environment, but I can't narrow it down.

我开始一个空的项目中,添加一个空白的活动,并接受所有默认值。项目设置完之后,我添加了一个设置活动。

I start an empty project, add a single "Blank" activity and accept all defaults. After the project finishes setting up, I add a "Settings" activity.

里面MainActivity.java,我加code两行两个活动连接,然后生成该项目。

Inside MainActivity.java, I add two lines of code to connect the two activities, and then build the project.

public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {

        Intent intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);

        return true;
    }

    return super.onOptionsItemSelected(item);
}

我的应用程序发送到调试,当我选择设置操作栏上,应用程序崩溃与

I send the application to debug, and when I pick "Settings" on the action bar, the application crashes with:

android.content.res.Resources$NotFoundException: File res/drawable/ic_sync_black_24dp.xml from drawable resource ID #0x7f020049

我收到此相同的错误上的虚拟影像,当我送APK到真实的物理设备,并尝试查看设置活动。

I get this same error on the virtual images, and when I send the APK to a real physical device and try to view the settings activity.

我已经开始新的清洁项目好几次,我也得到每个项目相同的结果。我试过干净版本,我已经试过删除R.java东西。当我看着RES /绘制/ ic_sync_black_24dp.xml在我的项目(​​这是由添加新活动向导创建),我可以看到图标,一切看起来正常。

I've started new and clean projects several times, and I get the same result with each project. I've tried clean builds, I've tried deleting the R.java stuff. When I look at the res/drawable/ic_sync_black_24dp.xml in my project (which was created by the add new activity wizard) I can see the icon and everything looks normal.

如果我删除指定此图标pref_headers.xml文件中的一条线,该项目构建的罚款,并设置活动有图标为其他两个选择,但不是ic_sync_black_24dp.xml图标。

If I remove the one line from the pref_headers.xml file that specifies this icon, the project builds fine, and the settings activity has icons for the other two choices, but not the ic_sync_black_24dp.xml icon.

下面是我手动从pref_headers.xml删除该行:

Here's the line I have to manually delete from pref_headers.xml:

    android:icon="@drawable/ic_sync_black_24dp"

因此​​,这是有效的pref_headers.xml为我的文件:

So this is the valid pref_headers.xml file for me:

<!-- These settings headers are only used on tablets. -->

<header
    android:fragment="com.schramauto.anothertrial.SettingsActivity$GeneralPreferenceFragment"
    android:icon="@drawable/ic_info_black_24dp"
    android:title="@string/pref_header_general" />

<header
    android:fragment="com.schramauto.anothertrial.SettingsActivity$NotificationPreferenceFragment"
    android:icon="@drawable/ic_notifications_black_24dp"
    android:title="@string/pref_header_notifications" />

<header
    android:fragment="com.schramauto.anothertrial.SettingsActivity$DataSyncPreferenceFragment"
    android:title="@string/pref_header_data_sync" />

在资源\\绘制,也有由添加的设置,活动向导增加了3 XML文件。对我来说所有3正常显示,并显示一个图标的有效preVIEW。

In res\drawable, there are a 3 xml files added by the wizard that added the settings activity. All 3 display properly for me and show a valid preview of an icon.

下面是好的XML内容,ic_info_black_24dp.xml:

Here is the contents of the "good" xml, ic_info_black_24dp.xml:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportHeight="24.0"
    android:viewportWidth="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
</vector>

下面是有问题的XML(ic_sync_black_24dp.xml):

Here is the questionable XML (ic_sync_black_24dp.xml):

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24.0dp"
    android:height="24.0dp"
    android:viewportHeight="24.0"
    android:viewportWidth="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
</vector>

同样,我已经试过这也许15倍(创建全新的项目和连接两个活动),重新启动,搜索谷歌,搜在这里,我想不出有什么不对ic_sync_black_24dp.xml向导放在我的项目。

Again, I've tried this maybe 15 times (creating brand new projects and connecting the two activities), rebooted, searched google, searched here, and I can't figure out what's wrong with ic_sync_black_24dp.xml that the wizard put in my project.

由于我做一个假设,这可能是我的IDE或我的本地构建配置环境,这里有我的一些设置高水平的细节:
10的Windows,Android的工作室1.5,JRE 1.8.0

Since I'm making an assumption that this may be environmental in my IDE or my local build configuration, here are some high level details on my setup: Windows 10, Android Studio 1.5, JRE 1.8.0

推荐答案

看来,问题与API 21躺着,被提及并没有解决这个问题,我不是,我收到24.0dp:

Seems that the issue lay with API 21, the 24.0dp that was mentioned did not solve the issue for me instead I was receiving:

E/PathParser: error in parsing "c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8"

我找到了答案在 https://github.com/google/material - 设计 - 图标/问题/ 225

原来,pathData是无效的不能在API 21解析正确(这个问题不API 22或23存在)。
简单地替换pathData:

It turns out the pathData is invalid cannot be parsed in API 21 properly (the problem does not exist in API 22 or 23). Simply replace the pathData with:

android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01 .25,-1.97 .7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z"

这篇关于android.content.res.Resources $ NotFoundException为ic_sync_black_24dp.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆