Use THEME_MATERIAL appear error log
tcqq opened this issue · 10 comments
@garretyoder If use THEME_MATERIAL
or THEME_MATERIAL_COMPONETS
, the following error will appear. What did i do wrong?
Code
ColorfulKt.Colorful().apply(this, true, BaseTheme.THEME_MATERIAL_COMPONETS);
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Log
AppCompatDelegate: Failed to instantiate custom view inflater android.support.design.theme.MaterialComponentsViewInflater . Falling back to default.
java.lang.ClassNotFoundException: Invalid name: android.support.design.theme.MaterialComponentsViewInflater
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1014)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
If you're inheriting your base style from Theme.MaterialComponets to use the new MaterialComponets theme, you need to add the new design library as a dependency to your project.
But I am using this version now: com.android.support:design:28.0.0-alpha1
, because "28.0.0-alpha1" version contains "material-components"
The material componets theme is still very much alpha as far as Google is concerned, hence the -alpha denotation. I recommend matching the version you're using to the version Colorful is using.
implementation 'com.google.android.material:material:1.0.0-alpha1'
the sdk28 version is depending on P. I don't plan on moving Colorful's SDK to android P until P's apis are marked stable in DP3.
Hi, I tested it, when I change the support library version from 28.0.0-alpha1 to 27.1.1 and add the com.google.android.material:material:1.0.0-alpha1
library, I get an error
The error is fixed when I change the support library version from 27.1.1 to 28-alpha1 and delete the com.google.android.material:material:1.0.0-alpha1
library
When I remove exclude group: 'com.google.android.material', module: 'material'
, the above error will appear again.
api (com.github.garretyoder:Colorful:2.3.2) {
exclude group: 'com.google.android.material', module: 'material'
}
If do not delete, the above error will not appear, but the log will have the following error.
AppCompatDelegate: Failed to instantiate custom view inflater android.support.design.theme.MaterialComponentsViewInflater . Falling back to default.
java.lang.ClassNotFoundException: Invalid name: android.support.design.theme.MaterialComponentsViewInflater
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1014)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
@garretyoder com.android.support
and com.google.android.material
cannot add at the same time.
I created a new project and tried to add it at the same time, occurred an error.
If I remove material
library, and change support library version to 28.0.0-alpha1
, now can run, but the log shows the following error
- If I change
Theme.MaterialComponents.Light.DarkActionBar
toTheme.AppCompat.Light.DarkActionBar
, the error will not appear. - Or if I click on refactoring to AndroidX after, Now I use
Theme.MaterialComponents.Light.DarkActionBar
, the error log will also not appear.
So fixing the following error I found two solutions:
- Support library use
28.0.0-alpha1
version , and useBaseTheme.THEME_APPCOMPAT
instead ofBaseTheme.THEME_MATERIAL
orBaseTheme.THEME_MATERIAL_COMPONETS
- Refactoring to AndroidX, and use
BaseTheme.THEME_APPCOMPAT
orBaseTheme.THEME_MATERIAL
orBaseTheme.THEME_MATERIAL_COMPONETS
Error log
AppCompatDelegate: Failed to instantiate custom view inflater android.support.design.theme.MaterialComponentsViewInflater . Falling back to default.
java.lang.ClassNotFoundException: Invalid name: android.support.design.theme.MaterialComponentsViewInflater
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1014)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
Refactoring to AndroidX will fix the issue. I might make another release later today to try to enable some build magic to support the material components theme without relying on the new design library until it's marked stable.
I have rolled back support for the material componets theme in the stable branch as it's bound to androidx and android P, and will cause build errors when not targeting android P. If you wish to use the material componets theme, I've moved it into a new branch called 'android-p' where you can build it.
Ok.