Reputation: 3265
I'm getting this crash report in Crashlytics:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.activities.TabActivity}: android.view.InflateException: Binary XML file line #27: Binary XML file line #9: Binary XML file line #9: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity + 2957(ActivityThread.java:2957)
at android.app.ActivityThread.handleLaunchActivity + 3032(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage + 1696(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage + 105(Handler.java:105)
at android.os.Looper.loop + 164(Looper.java:164)
at android.app.ActivityThread.main + 6942(ActivityThread.java:6942)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run + 327(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main + 1374(ZygoteInit.java:1374)
--
Caused by android.content.res.Resources$NotFoundException
Drawable (missing name) with resource ID #0x7f080060
Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f080060
This is my xml layout file:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:clickable="true"
android:focusable="true">
<RelativeLayout
android:id="@+id/layout_header"
android:layout_width="match_parent"
android:layout_height="@dimen/px_149"
android:background="@drawable/back_nav_new_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <ImageView
android:id="@+id/iv_theme_dark"
android:layout_width="@dimen/px_30"
android:layout_height="@dimen/px_30"
android:src="@color/old_background_main"
android:layout_marginBottom="@dimen/px_3"
android:layout_marginLeft="24dp"
app:layout_constraintBottom_toTopOf="@id/iv_theme_light"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="24dp" />
<ImageView
android:id="@+id/iv_theme_light"
android:layout_width="@dimen/px_30"
android:layout_height="@dimen/px_30"
app:layout_constraintBottom_toBottomOf="@id/layout_header"
android:layout_marginLeft="24dp"
android:src="@color/newColorPrimaryDark"
android:layout_marginTop="@dimen/px_3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_theme_dark"
android:layout_marginStart="24dp" />-->
<ImageView
android:id="@+id/iv_profile"
android:layout_width="@dimen/px_64"
android:layout_height="@dimen/px_64"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:contentDescription="@string/sample_description"
android:scaleType="fitXY"
android:src="@drawable/profile_avatar"
app:layout_constraintEnd_toEndOf="@id/layout_header"
app:layout_constraintTop_toTopOf="@id/layout_header" />
<TextView
android:id="@+id/nav_header_fullname"
android:layout_width="wrap_content"
android:layout_height="@dimen/px_30"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
android:textColor="@color/black_text"
android:textSize="@dimen/sp_15"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/iv_profile"
app:layout_constraintTop_toBottomOf="@id/iv_profile" />
<Button
android:id="@+id/btn_login"
style="@style/AppTheme.RoundedCornerCalenderButtonAllSellers"
android:layout_width="@dimen/px_65"
android:layout_height="@dimen/px_30"
android:layout_marginTop="@dimen/px_4"
android:text="@string/xml_log_and_reg_btn_login"
android:textColor="@color/black_text"
android:textSize="@dimen/sp_13"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/iv_profile"
app:layout_constraintTop_toBottomOf="@id/iv_profile" />
<TextView
android:id="@+id/nav_header_phonenumber"
android:layout_width="wrap_content"
android:layout_height="@dimen/px_30"
android:layout_marginBottom="12dp"
android:gravity="center_vertical"
android:text="@string/sample_mobile"
android:textColor="@color/black_text"
android:textSize="@dimen/sp_15"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/drawer_list"
app:layout_constraintEnd_toEndOf="@id/iv_profile" />
<Button
android:id="@+id/btn_register"
style="@style/AppTheme.RoundedCornerCalenderButtonAllSellers"
android:layout_width="@dimen/px_65"
android:layout_height="@dimen/px_30"
android:layout_marginTop="@dimen/px_4"
android:text="@string/register"
android:textColor="@color/black_text"
android:textSize="@dimen/sp_13"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/btn_login"
app:layout_constraintTop_toBottomOf="@id/btn_login" />
<ImageView
android:id="@+id/iv_launch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:contentDescription="@string/sample_description"
android:scaleX="-1"
android:src="@drawable/ic_launch"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@id/nav_header_phonenumber"
app:layout_constraintEnd_toStartOf="@id/nav_header_fullname"
app:layout_constraintTop_toBottomOf="@id/iv_profile"
app:layout_constraintVertical_bias="0.68" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/px_8"
app:layout_constraintTop_toBottomOf="@+id/layout_header" />
</androidx.constraintlayout.widget.ConstraintLayout>
This crash occurred 12 times in 4 devices. How can I solve this problem?
Upvotes: 11
Views: 5553
Reputation: 13
I just had the same weird problem with vector drawable assets with stock icons. Suddenly my_image.xml stopped displaying the actual png files in the design tab. I recreated and it started working again. If the image asset has an XML file, double-click the file and check the 'design' tab (among code/split/design) to see if the project is reading your asset correctly. With a broken file, the design tab showed nothing but a black background.
Upvotes: 0
Reputation: 1500
I think you need to check which folder has your drawables, moving it from drawable-v24 to drawable should help. Also, if you're working with multiple packages, ensure that you are adding the images to correct package's drawable folder. Clean and build, your error will be resolved. Hope it works, all the best.
Upvotes: -1
Reputation: 201
The same problem occurred when I created an app for version 28 and than tried to run it on a version 21 device. I had all my PNG files in "res/drawable", so it seemed. On closer look there was "(v24)" showing up in gray behind the file names. And in reality all files but one were in "res/drawable-v24". I moved them (outside Android Studio) to "res/drawable" and all was fine.
Upvotes: 3