[英]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”已经存在于以下文件夹中:
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.