简体   繁体   English

由 android.content.res.Resources$NotFoundException 引起:即使资源存在,资源 ID 也可绘制(缺少名称)

[英]Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID even the resource is there

On some Android devices, I am getting "Resources$NotFoundException: Drawable (missing name) with resource ID" error, eg:在某些 Android 设备上,我收到“Resources$NotFoundException: Drawable (missing name) with resource ID”错误,例如:

On LGE Android 8.1 devices it is complaining在 LGE Android 8.1 设备上它抱怨

Unable to start activity ComponentInfo{SplashActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class ImageView Unable to start activity ComponentInfo{SplashActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class ImageView

For the following part.对于以下部分。 In particular, it is complaining " android:src="@drawable/red_logo" "特别是抱怨“ android:src="@drawable/red_logo"

    <ImageView
    android:id="@+id/logoImageView"
    android:layout_width="wrap_content"
    android:layout_height="100dp"
    android:layout_marginStart="50dp"
    android:layout_marginEnd="50dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:src="@drawable/red_logo" />

I checked the source code directory, "red_logo.png" already exists in the following folders:我检查了源代码目录,“red_logo.png”已经存在于以下文件夹中:

  • drawable可绘制的
  • drawable-hdpi可绘制的 hdpi
  • drawable-ldpi可绘制的 ldpi
  • drawable-mdpi可绘制的 mdpi
  • drawable-xhdpi可绘制的 xhdpi
  • drawable-xxhdpi可绘制-xxhdpi
  • drawable-xxxhdpi可绘制的xxxhdpi

Here is the Java code这是Java代码

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash); <---- Fails here
}

The dimension of red_logo.png in drawable folder is 4864 × 2692, same size as the red_logo.png in drawable-xxxhdpi folder. drawable文件夹中red_logo.png的尺寸为4864×2692,与drawable-xxxhdpi文件夹中的red_logo.png大小相同。 Is it too big?是不是太大了?

I did a lot of research but it seems I cannot find a valid answer.我做了很多研究,但似乎找不到有效的答案。

Thank you.谢谢你。 Best regards.此致。

It happens due to scale issues, hence, always use a vector asset instead of an image in such scenarios.它是由于规模问题而发生的,因此,在这种情况下,始终使用矢量资产而不是图像。 Worked for me.为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 缺少资源 ID android.content.res.Resources$NotFoundException:字符串资源 ID #0xb - missing resource id android.content.res.Resources$NotFoundException: String resource ID #0xb android.content.res.Resources $ NotFoundException:资源ID#0x0可绘制 - android.content.res.Resources$NotFoundException: Resource ID #0x0 drawable android.content.res.Resources$NotFoundException · 字符串资源 ID # - android.content.res.Resources$NotFoundException · String resource ID # android.content.res.Resources $ NotFoundException:资源ID#0x0 - android.content.res.Resources$NotFoundException: Resource ID #0x0 android.content.res.Resources $ NotFoundException:无法找到资源ID - android.content.res.Resources$NotFoundException: Unable to find resource ID android.content.res.Resources$NotFoundException:可绘制的 compat_splash_screen_no_icon_background 资源 ID #0x7f0801b6 - android.content.res.Resources$NotFoundException: Drawable compat_splash_screen_no_icon_background with resource ID #0x7f0801b6 java.lang.ExceptionInInitializerError 原因:android.content.res.Resources$NotFoundException:字符串资源 - java.lang.ExceptionInInitializerError Caused by: android.content.res.Resources$NotFoundException: String resource android.content.res.Resources $ NotFoundException:资源ID#0x0 Android错误 - android.content.res.Resources$NotFoundException: Resource ID #0x0 Android error GridView.FATAL例外:main android.content.res.Resources $ NotFoundException:字符串资源ID#0x0 - GridView.FATAL EXCEPTION: main android.content.res.Resources$NotFoundException: String resource ID #0x0 无法访问变量-android.content.res.Resources $ NotFoundException:字符串资源ID - Can't get access to variables - android.content.res.Resources$NotFoundException: String resource ID
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM