After I updated my project to AndroidX
with targetSdkVersion
set to 28, my project crashes on installing it from the store for beta testing.
In my case the problem was the theme value in the Manifest file
<activity
android:name=".ui.BarcodeReaderDrawerActivity"
android:label="@string/title_activity_barcode_reader_drawer">
android:theme="@style/AppBaseTheme.NoActionBar"
</activity>
Changed in
<activity
android:name=".ui.BarcodeReaderDrawerActivity"
android:label="@string/title_activity_barcode_reader_drawer"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
</activity>
In my case, the issue is in navigation.NavigationView app:headerLayout layout I am setting
<ImageView
app:srcCompat="@mipmap/ic_launcher_round"
/>
and the problem is with ic_launcher_round because this is inside folder mipmap-anydpi-v26 and I am using android version 7.1.1 that is API Level: 25
hope this helps anyone
android.view.InflateException: means there is something wrong in your XML file itself.
Please check all your dimensions, color resources, and other resources you have assigned in the XML tag.
Or post your XML file here.
There are multiple reasons why this error can occur. Check the following and make sure they are proper:
drawable
and color
resources used inside the com.google.android.material.navigation.NavigationView
you've used, probably in activity_main.xml
, if you're using the default Navigation Drawer template code from Android Studio.res/drawable
folder, not in res/drawable-v21
.android:backgroundTint()
or android:src
or similar inside your NavigationView
. Since they don't work below android API Level 21, use app:backgroundTint
or app:srcCompat
instead.You can check your XML file. Something wrong in your xml like menu, nav header and other. In my Case, wrong in res/menu/menu.xml
For those who the chosen answer didn't help them, I've found that had a problem with NavigationView theme and it should be an appCompat theme (at least for me). after creating a new style like:
<style name="NavView" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
...
</style>
and used it with android:theme="@style/NavView" in NavigationView in my mainactivity.xml, the app runs perfectly now.