On some Android devices, I am getting "Resources$NotFoundException: Drawable (missing name) with resource ID" error, eg:
On LGE Android 8.1 devices it is complaining
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" "
<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:
Here is the Java code
@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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.