Material-dialogs: Release builds are shrinking layout files

Created on 5 May 2020  路  3Comments  路  Source: afollestad/material-dialogs

Library Version:

3.3.0

Describe the Bug:

Crashing in release builds with:

Fatal Exception: android.view.InflateException: Binary XML file line #1 in co.myapp.dev:layout/md_dialog_stub_recyclerview: Binary XML file line #1 in co.myapp.dev:layout/md_dialog_stub_recyclerview: Error inflating class x
Caused by android.view.InflateException: Binary XML file line #1 in co.myapp.dev:layout/md_dialog_stub_recyclerview: Error inflating class x
Caused by java.lang.ClassNotFoundException: android.view.x
       at java.lang.Class.classForName(Class.java)
       at java.lang.Class.forName(Class.java:454)
       at android.view.LayoutInflater.createView(LayoutInflater.java:815)
       at android.view.LayoutInflater.createView(LayoutInflater.java:776)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:913)
       at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:930)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:950)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
       at com.afollestad.materialdialogs.utils.ViewsKt.inflate(ViewsKt.java:39)
       at com.afollestad.materialdialogs.utils.ViewsKt.inflate$default(ViewsKt.java:38)
       at com.afollestad.materialdialogs.internal.message.DialogContentLayout.addRecyclerView(DialogContentLayout.java:104)
       at com.afollestad.materialdialogs.list.DialogListExtKt.customListAdapter(DialogListExtKt.java:66)
       at com.afollestad.materialdialogs.list.DialogListExtKt.customListAdapter$default(DialogListExtKt.java:64)
       at com.afollestad.materialdialogs.list.DialogListExtKt.listItems(DialogListExtKt.java:101)
       at com.afollestad.materialdialogs.list.DialogListExtKt.listItems$default(DialogListExtKt.java:86)
       at co.myapp.dialogs.Material_dialog_listKt.waitForChoice$$forInline(Material_dialog_listKt.java:20)
       at co.myapp.survey_card.related_people.SurveyCardRelatedPeopleInteractor.awaitMenuItemSelected-znP9nOI(SurveyCardRelatedPeopleInteractor.java:133)
       at co.myapp.survey_card.related_people.SurveyCardRelatedPeopleInteractor$awaitMenuItemSelected$1.invokeSuspend(SurveyCardRelatedPeopleInteractor.java:12)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:56)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7356)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

To Reproduce:

  1. Use a bottom sheet with listItems

Expected Behavior:

Not to crash

We use R8 in full mode.

Our fix is to add this to a keep.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
  tools:keep="@layout/md_dialog_*" />
bug core

Most helpful comment

Same here

Caused by: android.view.InflateException: Binary XML file line #1 in com.iven.musicplayergo:layout/md_dialog_stub_recyclerview: Error inflating class x

Edit: solved by adding a keep.xml file under /res/xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/md_dialog_stub_recyclerview" />

Thanks @peterhav @hanburn

All 3 comments

Thanks for posting this workaround. When using dialogs from the DateTime module, the following xml keep file is required:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/md_dialog_*,@layout/md_datetime_*" />

When using dialogs from the Color module, the follow xml keel file is required:
<?xml version="1.0" encoding="utf-8" ?> <resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@layout/md_dialog_*, @layout/md_color_*" />

Same here

Caused by: android.view.InflateException: Binary XML file line #1 in com.iven.musicplayergo:layout/md_dialog_stub_recyclerview: Error inflating class x

Edit: solved by adding a keep.xml file under /res/xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/md_dialog_stub_recyclerview" />

Thanks @peterhav @hanburn

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CHOIMINSEOK picture CHOIMINSEOK  路  8Comments

jahirfiquitiva picture jahirfiquitiva  路  6Comments

sarthak1996 picture sarthak1996  路  6Comments

dabo248 picture dabo248  路  7Comments

RezaOruji picture RezaOruji  路  3Comments