![](/img/trans.png)
[英]missing resource id android.content.res.Resources$NotFoundException: String resource ID #0xb
[英]Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID even the resource is there
在某些 Android 設備上,我收到“Resources$NotFoundException: Drawable (missing name) with resource ID”錯誤,例如:
在 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
對於以下部分。 特別是抱怨“ 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" />
我檢查了源代碼目錄,“red_logo.png”已經存在於以下文件夾中:
這是Java代碼
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash); <---- Fails here
}
drawable文件夾中red_logo.png的尺寸為4864×2692,與drawable-xxxhdpi文件夾中的red_logo.png大小相同。 是不是太大了?
我做了很多研究,但似乎找不到有效的答案。
謝謝你。 此致。
它是由於規模問題而發生的,因此,在這種情況下,始終使用矢量資產而不是圖像。 為我工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.