在某些 Android 设备上,我收到“Resources$NotFoundException: Drawable (missing name) with resource ID”错误,例如:
\n在 LGE Android 8.1 设备上,它会抱怨
\n\n\n无法启动活动 ComponentInfo{SplashActivity}:android.view.InflateException:二进制 XML 文件行 #20:二进制 XML 文件行 #20:膨胀类 ImageView 时出错
\n
对于以下部分。特别是,它抱怨“ android:src="@drawable/red_logo" ”
\n <ImageView\n android:id="@+id/logoImageView"\n android:layout_width="wrap_content"\n android:layout_height="100dp"\n android:layout_marginStart="50dp"\n android:layout_marginEnd="50dp"\n app:layout_constraintBottom_toBottomOf="parent"\n app:layout_constraintEnd_toEndOf="parent"\n app:layout_constraintStart_toStartOf="parent"\n app:layout_constraintTop_toTopOf="parent"\n android:src="@drawable/red_logo" />\nRun Code Online (Sandbox Code Playgroud)\n我检查了源代码目录,“red_logo.png”已经存在于以下文件夹中:
\n这是Java代码
\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_splash); <---- Fails here\n}\nRun Code Online (Sandbox Code Playgroud)\ndrawable文件夹中red_logo.png的尺寸为4864\xe2\x80\x8a\xc3\x97\xe2\x80\x8a2692,与drawable-xxxhdpi文件夹中red_logo.png大小相同。是不是太大了?
\n我做了很多研究,但似乎找不到有效的答案。
\n谢谢。\n最诚挚的问候。
\n