I get this error:
android.view.InflateException: Binary XML file line #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
I know there is a duplicate question, but the answers there do not solve my issue.
This is my build.gradle(app)
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 14
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v13:26.1.0'
implementation "com.android.support:support-fragment:26.1.0"
On the other duplicate question, the answer asked to downgrade the sdkVersion to 25. I tried that, but it broke my whole app. I need to add a lot of extra codes here and there, and remove certain features (notification channel for example) to make it compatible with SDK 25.
Is there anyway around this?
My FAB XML Code:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_addnew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:backgroundTint="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/ic_add_white_24px"
/>
Edit: Added on full log cat:
09-25 16:20:52.250 5637-5637/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 5637
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.OrderActivity}: android.view.InflateException: Binary XML file line #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #149: Binary XML file line #149: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.xxx.xxx.OrderActivity.onCreate(OrderActivity.java:72)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Edit: Added the rest of XML file as requested.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E0E0E0"
tools:context="com.xxx.xxx.OrderActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/header"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
app:layout_constraintTop_toTopOf="#+id/ConstraintLayout"
android:background="#color/white"
>
<ImageView
android:id="#+id/icon"
style="#style/ThemeOverlay.Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:contentDescription="#string/icon"
android:src="#drawable/local_icon"
app:layout_constraintLeft_toLeftOf="#+id/header"
app:layout_constraintTop_toTopOf="#+id/header"
app:layout_constraintBottom_toBottomOf="#+id/header"
android:layout_marginTop="#dimen/border_margin"
android:layout_marginStart="#dimen/border_margin"
android:layout_marginBottom="#dimen/border_margin"
/>
<TextView
android:id="#+id/org_ID"
style="#style/AppTheme.Subheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
tools:text="ABCD"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
android:layout_marginTop="#dimen/half_border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toTopOf="#+id/header"
/>
<TextView
android:id="#+id/user_ID"
style="#style/AppTheme.Subsubheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="35"
android:lines="1"
tools:text="abc123#gmail.com"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toBottomOf="#+id/org_ID"/>
<TextView
android:id="#+id/version"
style="#style/AppTheme.Subsubsubheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="30"
android:lines="1"
android:visibility="visible"
android:layout_marginStart="#dimen/border_margin"
app:layout_constraintLeft_toRightOf="#+id/icon"
app:layout_constraintTop_toBottomOf="#+id/user_ID"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_more_vert_black_24dp"
android:contentDescription="#string/desc_overflow_button"
android:onClick="showPopup"
app:layout_constraintTop_toTopOf="#+id/header"
app:layout_constraintBottom_toBottomOf="#+id/header"
app:layout_constraintRight_toRightOf="#+id/header"
android:background="#android:color/transparent"
android:layout_marginEnd="#dimen/border_margin2"
/>
</android.support.constraint.ConstraintLayout>
<TextView
android:id="#+id/order_ID"
style="#style/AppTheme.Subheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text="#string/store"
android:visibility="visible"
android:layout_marginStart="#dimen/double_border_margin"
app:layout_constraintBottom_toTopOf="#+id/recycler_orders"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintTop_toBottomOf="#+id/header" />
<Spinner
android:id="#+id/storespinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/recycler_orders"
app:layout_constraintLeft_toRightOf="#+id/order_ID"
app:layout_constraintTop_toBottomOf="#+id/header"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
android:visibility="visible"
android:layout_marginStart="0dp"
>
</Spinner>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_orders"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/ConstraintLayout"
app:layout_constraintLeft_toLeftOf="#+id/ConstraintLayout"
app:layout_constraintRight_toRightOf="#+id/ConstraintLayout"
app:layout_constraintTop_toBottomOf="#+id/order_ID"
tools:listitem="#layout/item_orders" />
<ProgressBar
android:id="#+id/progress_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/recycler_orders"
android:layout_alignTop="#+id/recycler_orders"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_addnew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:backgroundTint="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/ic_add_white_24px"
/>
</android.support.constraint.ConstraintLayout>
Edit: Add on styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
I've solved the issue. I found that
app:srcCompat="#drawable/ic_add_white_24px"
from my XML, the drawable file was in the v24 folder, that's what causing the error.
(stupid me)
Related
This question already has answers here:
Android Studio keeps refusing to resolve com.android.support:appcompat-v7:29.0.1
(6 answers)
Closed 3 years ago.
I am working on android project
and now in my layout I have this error:
The following classes could not be found:
- android.support.v4.widget.SwipeRefreshLayout (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.RecyclerView (Fix Build Path, Edit XML, Create Class)
I tried many selotions in stackOverFlow and other, but I faild to solove my problem.
Also I have this FATAL error in the logcat:
2019-08-18 15:36:08.069 13405-13405/com.example.souqsenae E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.souqsenae, PID: 13405
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.souqsenae/com.example.souqsenae.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.v7.widget.CardView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3548)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:7539)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.v7.widget.CardView
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.support.v7.widget.CardView
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.CardView" on path: DexPathList[[zip file "/data/app/com.example.souqsenae-0cR1gMxdpqx9a6GmZb9xEw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.souqsenae-0cR1gMxdpqx9a6GmZb9xEw==/lib/arm64, /system/lib64, /product/lib64]]
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "70dp"
android:elevation="24dp"
android:padding="8dp"
android:background="#drawable/white_action_bar"
android:id="#+id/first"
android:orientation="horizontal"
android:weightSum="1">
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/ic_my_location_black_24dp"
android:drawableStart="#drawable/ic_search_black_24dp"
android:drawableTint="#color/gray"
android:hint="#string/search"
android:textColorHint="#color/gray"
android:background="#drawable/stroke_gray"
android:padding="8dp"
android:layout_margin="2dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/white_action_bar"
android:layout_below="#id/first"
android:orientation="horizontal"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:weightSum="1"
android:id="#+id/taskBar">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/new_"
android:background="#android:color/transparent"
android:textColor="#color/colorAccent"
android:layout_weight="0.45"
android:id="#+id/btnAvailable"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:gravity="center"
android:text="#string/small_divider"
android:textColor="#color/colorPrimaryDark"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/used"
android:background="#android:color/transparent"
android:textColor="#color/colorPrimaryDark"
android:layout_weight="0.45"
android:id="#+id/btnMyJob"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:elevation="24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:id="#+id/layout_task_item"
android:layout_below="#id/taskBar">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="#+id/view2"
app:cardCornerRadius="15dp"
android:innerRadius="0dp"
android:shape="rectangle"
android:thicknessRatio="1.9"
android:layout_margin="8dp"
>
<ImageView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:id="#+id/imageView1"
android:src="#drawable/ic_image_black_24dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
</ImageView>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:padding="8dp"
android:textSize="20sp"
android:textColor="#color/colorPrimaryDark"
android:id="#+id/tvClientName"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:padding="8dp"
android:textSize="12sp"
android:textColor="#color/colorPrimaryDark"
android:id="#+id/tvTaskType"
android:textStyle="italic"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:padding="8dp"
android:textSize="12sp"
android:textColor="#color/black"
android:id="#+id/tvTaskDesc"
android:textStyle="italic"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/layout_task_item"
android:gravity="center"
android:id="#+id/listContainer"
android:layout_marginBottom="60dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/no_data"
android:text="#string/no_data"
android:textSize="24sp"
android:textAlignment="center"
android:gravity="center"
android:textColor="#color/colorPrimary" />
<ProgressBar
android:foregroundGravity="center"
android:id="#+id/progress"
android:layout_below="#+id/no_data"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:layout_centerInParent="true"/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/listTasks"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "50dp"
android:padding="2dp"
android:id="#+id/end"
android:orientation="horizontal"
android:background="#drawable/white_menu_bar"
android:weightSum="1"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#android:color/transparent"
android:text="#string/home"
android:textColor="#color/colorPrimaryDark"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#android:color/transparent"
android:text="#string/my_order"
android:textColor="#color/colorPrimaryDark"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#android:color/transparent"
android:text="#string/notifications"
android:textColor="#color/colorPrimaryDark"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#android:color/transparent"
android:drawableTop="#drawable/ic_menu_black_24dp"
android:layout_marginTop="12dp"
android:drawableTint="#color/colorPrimaryDark"/>
</LinearLayout>
</RelativeLayout>
and this is my style file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
I add 'Base' word as an seotion I found it but also not work..
The dependencies:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
testImplementation 'junit:junit:4.13-beta-3'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation 'com.android.support:appcompat-v7:29.0.0'
implementation 'com.android.support:design:29.0.0'
implementation 'com.android.support:cardview-v7:29.0.0'
implementation 'com.android.support:support-v4:29.0.0'
any help please?
Firstly
By now you should be aware that with the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack
Support Library version 28.0.0 is the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX. There is nothing like ...support:v29.0.0 so I doubt if your project will build successfully.
Secondly
You cannot mix both support and androidx libraries together in the same project, there will surely be conflicts unless you're using Jetpack tool. Migrate your support libraries to androidx using this Artifacts mapping
*And Finally**
References in an Androidx layout file should all be androidx artifacts and not otherwise.
Hence tag like this:
<android.support.v7.widget.CardView
android:layout_width="match_parent
Should be:
<androidx.cardview.widget.CardView
android:layout_width="match_parent
Try this:
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
androidx.cardview.widget.CardView
androidx.recyclerview.widget.RecyclerView
instead of
android.support.v4.widget.SwipeRefreshLayout
android.support.v7.widget.CardView
android.support.v7.widget.RecyclerView
You are using both support library and androidx library. Either use support library or use androidx
Use androidx library :
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
androidx.cardview.widget.CardView
androidx.recyclerview.widget.RecyclerView
instead of
android.support.v4.widget.SwipeRefreshLayout
android.support.v7.widget.CardView
android.support.v7.widget.RecyclerView
And in grade file add dependencies for androidx card view, swipe refresh layout and recyclerview.
Also, see Migrating to AndroidX
https://developer.android.com/jetpack/androidx/migrate
First of all, I know that Material Components 1.1.0 is still in alpha and I am aware, that it can be unstable, but I am interested in some solution. It still could be some problem in my code.
I am creating Alert Dialog with custom view and it is just crashing with such logs. It is working perfectly on some devices and just crashing on other.
android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_dialog_material_background.xml from color state list resource ID #0x7f080019
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2750)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid color state list tag inset
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:217)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2746)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Here is my XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:background="?attr/colorBackgroundSecondary"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp">
<TextView
android:id="#+id/screenTesterOptionsLayoutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-medium"
android:text="#string/screen_tester_dialog_title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical">
<Switch
android:id="#+id/screenTesterOptionsDifferentColors"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_different_colors" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsCoordinates"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_coordinates" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsLines"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_lines" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsVibration"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration" />
<View
android:id="#+id/screenTesterOptionsVibrationIntensityDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<TextView
android:id="#+id/screenTesterOptionsVibrationIntensityTitle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="#string/screen_tester_dialog_vibration_intensity"
android:textColor="?android:attr/textColorPrimary" />
<RadioGroup
android:id="#+id/screenTesterOptionsVibrationIntensitySelection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp">
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityLow"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_low"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityMedium"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_medium"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityHigh"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_high"
android:textColor="?android:attr/textColorSecondary" />
</RadioGroup>
<com.google.android.material.button.MaterialButton
android:id="#+id/screenTesterOptionsLayoutButtonApply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="8dp"
android:text="#string/screen_tester_dialog_action_apply"
android:textColor="?attr/colorAccent" />
</LinearLayout>
</ScrollView>
If you think, that it is some bug in framework I will just open issue in Google's issue tracker.
The only solution that i found for now is to supercharge the dialog theme overlay :
<style name="Theme.App" parent="Theme.MaterialComponents.Light.NoActionBar" />
<item name="materialAlertDialogTheme">#style/ThemeOverlay.App.MaterialAlertDialog</item>
</style>
<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:windowBackground">#color/white</item>
</style>
So around 1% of my daily users are haunted with the NavigationView exception which is caused by an image resource not being found. I find that strange, 99% of other users are just fine. I was hoping that updating my dependancies in version iterations will resolve the issue itself, but unfortunately, this error has stayed in my Crashlytics logs for 6 iterations already and it's the worst crash that is affecting my users.
The obvious thing would be that it is specific to older devices, but this would be a wrong assumption. It is not device specific, neither version specific. Although some specifics can be pointed out
Android Version
90% Andorid 8
10% Android 7
Device
Huawei 50%
Samsung 50%
Two relevant dependancies i'm using:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
The relevant piece of code in the XML layout:
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:headerLayout="#layout/layout_drawer_header2"
app:menu="#menu/navigation" />
The Header layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/authWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
tools:layout_width="240dp">
<TextView
android:id="#+id/number"
style="#style/Base.TextAppearance.AppCompat.Display3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:fontFamily="sans-serif-medium"
android:textColor="?android:textColorPrimary"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/car"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/driver"
tools:text="#01" />
<ImageView
android:id="#+id/driverIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/driver"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/driver"
app:srcCompat="#drawable/ic_person_white_24dp" />
<TextView
android:id="#+id/driver"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:layout_marginTop="16dp"
android:drawablePadding="8dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/driverIcon"
app:layout_constraintTop_toTopOf="parent"
tools:text="Drivers name" />
<ImageView
android:id="#+id/coDriverIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/codriver"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/codriver"
app:srcCompat="#drawable/ic_person_white_24dp" />
<TextView
android:id="#+id/codriver"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:drawablePadding="8dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/coDriverIcon"
app:layout_constraintTop_toBottomOf="#+id/driver"
tools:text="Co-Driver name" />
<ImageView
android:id="#+id/carIcon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
app:layout_constraintBottom_toBottomOf="#+id/car"
app:layout_constraintStart_toEndOf="#+id/number"
app:layout_constraintTop_toTopOf="#+id/car"
app:srcCompat="#drawable/ic_car_white_24dp" />
<TextView
android:id="#+id/car"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:ellipsize="end"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/carIcon"
app:layout_constraintTop_toBottomOf="#+id/codriver"
tools:text="Racing Car" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="#+id/image"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:srcCompat="#drawable/ic_account_circle_white_24dp" />
<ImageView
android:id="#+id/logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:padding="12dp"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_log_out" />
</RelativeLayout>
<TextView
android:id="#+id/switchText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="16dp"
android:layout_marginRight="8dp"
android:autoLink="web"
android:gravity="center_vertical"
android:maxLines="2"
android:text="#string/track_me_on_racelivemaps_com"
app:layout_constraintEnd_toStartOf="#+id/trackingOn"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/number" />
<Switch
android:layout_width="wrap_content"
android:id="#+id/trackingOn"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_height="wrap_content"
android:padding="8dp"
android:autoLink="web"
android:gravity="center_vertical"
android:maxLines="2"
app:layout_constraintBottom_toBottomOf="#+id/switchText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/switchText" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:text="#string/active_stage"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Body2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/switchText" />
<Spinner
android:id="#+id/activeStage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView12" />
</androidx.constraintlayout.widget.ConstraintLayout>
The menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="#string/mode">
<menu>
<group android:checkableBehavior="single">
<item
android:id="#+id/recce"
android:icon="#drawable/ic_write_black_24dp"
android:title="#string/reccemode" />
<item
android:id="#+id/liaison"
android:icon="#drawable/ic_route_black_24dp"
android:title="#string/liaisonmode" />
<item
android:id="#+id/racing"
android:icon="#drawable/ic_racing_flag_black_24dp"
android:title="#string/racemode" />
<item
android:id="#+id/tsd"
android:icon="#drawable/ic_timer_black_24dp"
android:title="#string/tsd" />
<item
android:id="#+id/tsd_advanced"
android:icon="#drawable/ic_tsd_advanced"
android:title="#string/tsd_advanced" />
<item
android:id="#+id/custom_1"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_1" />
<item
android:id="#+id/custom_2"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_2" />
<item
android:id="#+id/custom_3"
android:icon="#drawable/ic_navigation_layout"
android:title="#string/custom_layout_3" />
</group>
</menu>
</item>
<group android:checkableBehavior="none">
<item
android:id="#+id/stages"
android:icon="#drawable/ic_stage_black_24dp"
android:title="#string/special_stages" />
<item
android:id="#+id/settings"
android:icon="#drawable/ic_settings_black_24dp"
android:title="#string/settings" />
<item
android:id="#+id/customize_ui"
android:icon="#drawable/ic_layout_edit"
android:title="#string/customize_ui" />
<item
android:id="#+id/weather"
android:icon="#drawable/ic_weather"
android:title="#string/weather" />
<item
android:id="#+id/login"
android:icon="#drawable/ic_key_white_24dp"
android:title="#string/log_in" />
<item
android:id="#+id/manual"
android:icon="#drawable/ic_manual"
android:title="#string/user_manual" />
<item
android:id="#+id/language"
android:icon="#drawable/ic_translate"
android:title="#string/language" />
<item
android:id="#+id/invite"
android:icon="#drawable/ic_share_black_24dp"
android:title="#string/invite" />
<item
android:id="#+id/feedback"
android:icon="#drawable/ic_feedback_black_24dp"
android:title="#string/feedback_report_bug" />
<item
android:id="#+id/tester"
android:icon="#drawable/ic_tester"
android:title="#string/become_a_tester" />
<item
android:id="#+id/policy"
android:icon="#drawable/ic_policy"
android:title="#string/privacy_policy" />
<item
android:id="#+id/logoff"
android:icon="#drawable/ic_key_white_24dp"
android:title="#string/log_off" />
<item
android:id="#+id/exit"
android:icon="#drawable/ic_exit_to_app_black_24dp"
android:title="#string/exit" />
</group>
</menu>
And finally the crash logs.
android.view.InflateException: Binary XML file line #48: Binary XML
file line #48: Error inflating class
com.google.android.material.navigation.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3173)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by android.view.InflateException: Binary XML file line #48:
Binary XML file line #48: Error inflating class
com.google.android.material.navigation.NavigationView
Caused by android.view.InflateException: Binary XML file line #48:
Error inflating class
com.google.android.material.navigation.NavigationView
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ee.siimplangi.rallytripmeter.activities.MainActivity.onCreate(MainActivity.kt:186)
at android.app.Activity.performCreate(Activity.java:7358)
at android.app.Activity.performCreate(Activity.java:7349)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1219)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3126)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by android.view.InflateException: Binary XML file line #29:
Binary XML file line #29: Error inflating class ImageView
Caused by android.view.InflateException: Binary XML file line #29:
Error inflating class ImageView
Caused by android.content.res.Resources$NotFoundException: Resource ID
0x7f0800a5
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:290)
at android.content.res.Resources.getValue(Resources.java:1476)
at androidx.appcompat.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:235)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:78)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:68)
at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:783)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.google.android.material.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207)
at com.google.android.material.navigation.NavigationView.inflateHeaderView(NavigationView.java:281)
at com.google.android.material.navigation.NavigationView.(NavigationView.java:193)
at com.google.android.material.navigation.NavigationView.(NavigationView.java:104)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ee.siimplangi.rallytripmeter.activities.MainActivity.onCreate(MainActivity.kt:186)
at android.app.Activity.performCreate(Activity.java:7358)
at android.app.Activity.performCreate(Activity.java:7349)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1219)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3126)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
at android.app.ActivityThread.-wrap12(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1894)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
after reading the comments , first of all you have to use android:src because you are not using vector drawable.
This problem occur when we paste image from explorer to drawable folder then it ask whether to copy drawable or drawable-v24 and if you have pasted images in both directory structures, or have one more images with different directory structure then it will show this error, make sure to delete the icon from drawable-v24 after moving it to drawable folder , and clean the project and then run it will work .
Note: My app is working fine on old device android 5.But i am geeting this problem in newer versions.Now i have added the code for login and spinner....
I think it may be the problem of density pixels of images..or placing the things in wrong places.I need time from experts.Kindly Solve my problem.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawable="#color/colorAccent"
tools:context=".LoginActivity">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="0dp"
android:layout_height="512dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_marginTop="60dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="98dp"
android:elevation="4dp"
app:srcCompat="#drawable/logo_new"
tools:ignore="ContentDescription,UnusedAttribute" />
<android.support.design.widget.TextInputLayout
style="auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<EditText
android:id="#+id/tv_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/username"
android:imeOptions="actionNext"
android:inputType="text"
android:lines="1"
android:textSize="20sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/tv_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:lines="1"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Display1"
android:textSize="20sp"
tools:inputType="textPassword|textVisiblePassword" />
</android.support.design.widget.TextInputLayout>
<Button
android:onClick="login"
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:elevation="4dp"
android:text="#string/log_in"
android:textAllCaps="false"
android:textColor="#ffff" />
<TextView
android:textColor="#701212"
android:layout_marginTop="6dp"
android:layout_gravity="center"
android:text="#string/forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:popupBackground="?android:attr/textColorHighlightInverse"
android:theme="#style/AlertDialog.AppCompat.Light"/>
</RelativeLayout>
<View
android:background="#701212"
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="450dp"
android:layout_marginBottom="17dp"
app:layout_constraintBottom_toTopOf="#+id/textView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_marginTop="10dp"
android:textColor="#097779"
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/designed_and_develop_by"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/view" />
<TextView
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textColor="#730b72"
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="11dp"
android:text="#string/db_scholars"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view" />
</android.support.constraint.ConstraintLayout>
.
Thanks in advance
Process: com.example.muhammadobaid.sims, PID: 18834
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.muhammadobaid.sims/com.example.muhammadobaid.sims.LoginActivity}: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
Caused by: android.view.InflateException: Binary XML file line #98: Error inflating class Spinner
Caused by: android.content.res.Resources$NotFoundException: Drawable android:color/highlighted_text_material with resource ID #0x1060118
Caused by: android.content.res.Resources$NotFoundException: File res/color/highlighted_text_material.xml from drawable resource ID #0x1060118
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:1015)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:791)
at android.content.res.Resources.loadDrawable(Resources.java:1019)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.widget.PopupWindow.<init>(PopupWindow.java:286)
at android.widget.ColorPopupWindow.<init>(ColorPopupWindow.java:77)
at android.widget.ColorListPopupWindow.createPopupWindow(ColorListPopupWindow.java:90)
at android.widget.ListPopupWindow.<init>(ListPopupWindow.java:246)
at android.widget.ColorListPopupWindow.<init>(ColorListPopupWindow.java:82)
at android.widget.Spinner$DropdownPopup.<init>(Spinner.java:1202)
at android.widget.Spinner.createDropdownPopup(Spinner.java:1333)
at android.widget.Spinner.<init>(Spinner.java:294)
at android.widget.Spinner.<init>(Spinner.java:222)
at android.widget.Spinner.<init>(Spinner.java:172)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:195)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:166)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:147)
at android.support.v7.widget.AppCompatSpinner.<init>(AppCompatSpinner.java:132)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:115)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1016)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1073)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.muhammadobaid.sims.LoginActivity.onCreate(LoginActivity.java:52)
at android.app.Activity.performCreate(Activity.java:6974)
09-30 22:57:56.275 18834-18834/com.example.muhammadobaid.sims E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
**Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #19: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at** android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:183)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:116)
at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1232)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1205)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:998)
... 44 more
Caused by: android.content.res.Resources$NotFoundException: Drawable
android:color/highlighted_text_material with resource ID #0x1060118
That's a NotFoundException which means it couldn't find such color-file anything in this path:
res/color/highlighted_text_material.xml
You should probably change this.
Also, I just saw that there is another issue with the Spinner:
Caused by: android.view.InflateException: Binary XML file line #98: Binary XML file line #98: Error inflating class Spinner
I'm suspecting about this part:
android:popupBackground="?android:attr/textColorHighlightInverse"
Try changing the color to a not private resource.
The another issue is:
<item> tag requires a 'drawable' attribute or child tag defining a drawable
Add what it says to your drawable file: requires a 'drawable' attribute or child tag defining a drawable
Im working on an android app and when I test it on devices/emulators with api 21 and lower it crashes and gives me a message in the logs:
09-29 07:32:30.349 6212-6212/org.jazmawy.mahmood.vocabulary
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.jazmawy.mahmood.vocabulary, PID: 6212
java.lang.RuntimeException: Unable to start activity
ComponentInfo{org.jazmawy.mahmood.vocabulary/org.jazmawy.mahmood.vocabulary.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at
org.jazmawy.mahmood.vocabulary.MainActivity.onCreate(MainActivity.java:52)
if I remove the XML elements the app launches and prompts to MainActivity
and It seems that screen sizes doesn't affect the result to my observation its due to the API but i could be wrong
Here is the XML code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/green"
android:contentDescription="#string/app_name" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
android:weightSum="4"
app:layout_constraintBottom_toTopOf="#+id/mainActivityAdView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="#+id/button11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/vocabulary_button"
android:onClick="openUnitActivity" />
<Button
android:id="#+id/button13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/collection_button"
android:onClick="collectionOnClick" />
<Button
android:id="#+id/button9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/contact_us_button"
android:onClick="contactsUsOnClick" />
<Button
android:id="#+id/button14"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/aboutus_button"
android:onClick="aboutUsOnClick" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/mainActivityAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
ads:adSize="BANNER"
ads:adUnitId="AD_UNIT_ID"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
I tried cleaning some unnecessary XML attributes but it doesn't help
What should I try next?
its quite simple paste your image into the drawable and change tha path into app\src\main\res\drawable