collapsingtoolbarlayout-subtitle icon indicating copy to clipboard operation
collapsingtoolbarlayout-subtitle copied to clipboard

Error inflating class com.google.android.material.appbar.SubtitleCollapsingToolbarLayout

Open cleberpublitz opened this issue 3 years ago • 16 comments
trafficstars

implementation "com.google.android.material:material:1.5.0"
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.3.0-SNAPSHOT"
java.lang.RuntimeException: Unable to start activity ComponentInfo{care.viva.app/care.viva.app.profissional.views.ReciboActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:169)
        at android.app.ActivityThread.main(ActivityThread.java:6521)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
     Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at care.viva.app.databinding.ActivityReciboBinding.inflate(ActivityReciboBinding.java:184)
        at care.viva.app.databinding.ActivityReciboBinding.inflate(ActivityReciboBinding.java:178)
        at care.viva.app.profissional.views.ReciboActivity.onCreate(ReciboActivity.kt:39)
        at android.app.Activity.performCreate(Activity.java:7051)
        at android.app.Activity.performCreate(Activity.java:7042)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:169)
        at android.app.ActivityThread.main(ActivityThread.java:6521)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.IllegalAccessError: Field 'com.google.android.material.resources.TextAppearance.textColor' is inaccessible to class 'com.google.android.material.internal.SubtitleCollapsingTextHelper' (declaration of 'com.google.android.material.internal.SubtitleCollapsingTextHelper' appears in /data/app/care.viva.app-LvNQ-soKPeFPmhHXCBr0Fw==/base.apk!classes18.dex)
        at com.google.android.material.internal.SubtitleCollapsingTextHelper.setExpandedTitleTextAppearance(SubtitleCollapsingTextHelper.java:356)
        at com.google.android.material.appbar.SubtitleCollapsingToolbarLayout.<init>(SubtitleCollapsingToolbarLayout.java:132)
2022-02-22 10:38:21.594 10181-10181/care.viva.app E/AndroidRuntime:     at com.google.android.material.appbar.SubtitleCollapsingToolbarLayout.<init>(SubtitleCollapsingToolbarLayout.java:84)

cleberpublitz avatar Feb 22 '22 13:02 cleberpublitz

It's because the material library v1.5.0 changed its API. I created a PR https://github.com/hendraanggrian/collapsingtoolbarlayout-subtitle/pull/41 to fix it.

@hendraanggrian could you have a look?

baole avatar Mar 11 '22 08:03 baole

@baole Thanks for the PR. Run into the same issue. How are you working around it at the moment? Thanks!

asuraphel avatar Apr 15 '22 11:04 asuraphel

@hendraanggrian could you have a look at @baole's PR please 🙏

ArthurCowboy avatar Jun 20 '22 08:06 ArthurCowboy

@hendraanggrian could you have a look at @baole's PR please 🙏

I will tonight. I'm sorry I wasn't here more often, I truly am.

hanggrian avatar Jun 20 '22 08:06 hanggrian

Thanks a lot @hendraanggrian 🔥

ArthurCowboy avatar Jun 20 '22 09:06 ArthurCowboy

It's taking longer than what was expected because I intend to release every major material versions.

I have published non-snapshot version 1.1.0, now I'm working on 1.2.0.

hanggrian avatar Jun 21 '22 19:06 hanggrian

@hendraanggrian thanks for the library. I think it's best to work backwards from the latest version. We had to move away from your library because another library required the latest material version and I think that's what most developers are on at this time.

asuraphel avatar Jun 21 '22 19:06 asuraphel

I'm sorry to disappoint, but growing the version incrementally allows me to implement features it is supposed to inherit.

Like for instance with version 1.2.0, multilining title and subtitle now works.

hanggrian avatar Jun 26 '22 19:06 hanggrian

Version 1.5.0-SNAPSHOT has been released. I will also publish the release version soon. I'll be glad if you guys can try it first and see what am I missing in this version.

hanggrian avatar Jul 01 '22 19:07 hanggrian

@hendraanggrian Thanks!

asuraphel avatar Jul 02 '22 14:07 asuraphel

@hendraanggrian keep me posted when you release the 1.5.0, gradle doesn't seems to find the snapshot on my side :/

ArthurCowboy avatar Jul 02 '22 14:07 ArthurCowboy

Version 1.5.0 has been released with everything working but Material You styling. By the time I realized it was missing, the package has already been published.

If you use Theme.Material3 in your app, it will still appear as if it was still in Theme.MaterialComponents.

I intend to fix it with version 1.6.0.

hanggrian avatar Jul 03 '22 00:07 hanggrian

Thanks!

ArthurCowboy avatar Jul 03 '22 15:07 ArthurCowboy

I'm seeing a similar inflate crash in 1.5.0 around setExpandedTextAppearance() in CollapsingTextHelper2. It looks like the getTextColor() method has been removed from TextAppearance causing the crash. Will this be fixed in 1.6.0 as well?

     Caused by: java.lang.NoSuchMethodError: No virtual method getTextColor()Landroid/content/res/ColorStateList; in class Lcom/google/android/material/resources/TextAppearance; or its super classes (declaration of 'com.google.android.material.resources.TextAppearance' appears in /data/app/~~R0w0z5GCXtBOIKWfIo5KRA==/com.ibotta.android-ULjP3LkscCrAWd9CzwZe-g==/base.apk!classes8.dex)
        at com.google.android.material.internal.CollapsingTextHelper2.setExpandedTextAppearance(CollapsingTextHelper2.java:525)
        at com.google.android.material.appbar.SubtitleCollapsingToolbarLayout.<init>(SubtitleCollapsingToolbarLayout.java:170)
       

IDMCI avatar Jul 12 '22 00:07 IDMCI

@IDMCI I find this rather odd since TextAppearance#getTextColor() is present in material 1.5.0 and 1.6.0. It is called in CollapsingTextHelper, and therefore CollapsingTextHelper2 too. Can you state material version you are on?

The snapshot of version 1.6.0 is available to try. Though I suspect you're going to run into the same issue.

hanggrian avatar Jul 12 '22 20:07 hanggrian

@hendraanggrian That was it! Thank you soooo much! I thought it was strange that method just disappeared, lol. Turns out we had held back on updating material because of another issue that's since been resolved. So now everything works!

IDMCI avatar Jul 14 '22 21:07 IDMCI

Thanks everyone for participating.

hanggrian avatar Aug 30 '23 18:08 hanggrian