My app crashes when trying to inflate the com.google.android.material.chip.Chipclass.
The dependency i am using is implementation 'com.google.android.material:material:1.0.0'
Here is my XML code
<com.google.android.material.chip.Chip
android:id="#+id/chipActive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipCornerRadius="5dp"
android:backgroundTint="#color/primaryColor"
android:textColor="#color/primaryTextColor"
android:textAlignment="center"
android:fontFamily="#font/roboto_regular"
android:layout_marginStart="10dp"
android:text="Active"/>
The error I get is
android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class com.google.android.material.chip.Chip
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
I found a question similar to mine on another thread but there was no solution there that was helpful to me. If anyone has any suggestions on how to fix this issue please help me :D
I found the solution just after posting this question. I updated the dependency to implementation 'com.google.android.material:material:1.1.0-alpha02' and now it works fine.
Use Theme <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
Put this code in the chip
android:theme="#style/Theme.MaterialComponents.Light"
Related
After migration to AndroidX my app crashes after calling Snackbar.make() method. The error looks like
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.internal.SnackbarContentLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.internal.SnackbarContentLayout"
It's strange that internal Snackbar method make() is still trying to access SnackbarContentLayout class in old support package instead new material's one. Please advice what I'm doing wrong.
UPDATE
Finally I found a solution. There is a custom layout in my project which overrides
Snackbar's design_layout_snackbar_include and it had wrong class in root view tag:
<view
xmlns:android="http://schemas.android.com/apk/res/android"
class="android.support.design.internal.SnackbarContentLayout"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
I changed it to com.google.android.material.snackbar.SnackbarContentLayout
ensure that your project is set up to migrate old packages to Androidx by including this in your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
I'm trying to use the Barrier view in ConstraintLayout:
<android.support.constraint.Barrier
android:id="#+id/buttonBarrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="top"
app:constraint_referenced_ids="answer1Button,answer2Button"
/>
It works fine in the IDE, and I get Barrier-specific lint messages. But when I run the app, it crashes trying to inflate the layout containing the Barrier:
java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.Barrier"
I am using AndroidX ConstraintLayout 1.1.3:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
What's happening here?
The xml tag is androidx.constraintlayout.widget.Barrier in the latest AndroidX version.
I'm face to a problem with chip component on android.
I try to implemente a chip like this:
<android.support.design.chip.Chip
android:id="#+id/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello world"/>
But when I launch my app I have this error:
android.view.InflateException: Binary XML file line #59: Binary XML file line #59: Error inflating class
android.support.design.chip.Chip
Caused by: android.view.InflateException: Binary XML file line #59:
Error inflating class android.support.design.chip.Chip
Caused by: java.lang.IllegalArgumentException: The style on this
component requires your app theme to be Theme.AppCompat (or a
descendant).
My style is already an AppCompact.
You need to use app theme to Theme.MaterialComponents.Light.Bridge inspite of AppCompat if you want to use android.support.design.chip.Chip.
Reason:
Chip component relies on new MaterialComponents theme, so is why the
crash occurs. Bridge theme here are treated as AppCompat but
provides new MaterialComponents theme when needed.
Im trying to use an Android component I found on Github. Using the sample project inside the repository I integrated the component into my app but everytime I run it I get the error: android.view.InflateException: Binary XML file line #8: Error inflating class com.yalantis.flip.sample.views.FontTextView. This FontTextView has been used in the sample project which runs just fine. Im not sure what im doing wrong as I have also copied and pasted their layouts. I thought my images were the problem but I used the original pictures used in the sample application and it still crashed.
Here is the text from my logcat:
`android.view.InflateException: Binary XML file line #8: Error inflating class com.yalantis.flip.sample.views.FontTextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at cc.tungait.voiture.activities.MainActivity$CarsAdapter.getPage(MainActivity.java:117)
at com.yalantis.flipviewpager.adapter.BaseFlipAdapter$MergeAdapter.getView(BaseFlipAdapter.java:124)
at com.yalantis.flipviewpager.view.FlipViewPager.setAdapter(FlipViewPager.java:468)
at com.yalantis.flipviewpager.adapter.BaseFlipAdapter.getView(BaseFlipAdapter.java:72)`
The XML is exactly what's in the sample project:
`
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Nickname"
android:id="#+id/nickname" />
<LinearLayout
android:layout_below="#+id/nickname"
android:id="#+id/interestsPrimary"
style="#style/LinearLayout.Interests">
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_1" />
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_2" />
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_3" />
</LinearLayout>
<LinearLayout
android:layout_below="#+id/interestsPrimary"
android:id="#+id/interestsSecondary"
android:layout_marginTop="5dp"
style="#style/LinearLayout.Interests">
<com.yalantis.flip.sample.views.FontTextView
android:id="#+id/interest_4"
style="#style/TextView.Interest" />
<com.yalantis.flip.sample.views.FontTextView
android:id="#+id/interest_5"
style="#style/TextView.Interest" />
</LinearLayout>
`
You have to change the package name of your FontTextView in your XML like package_name.FontTextView.
Like below
<LinearLayout
android:layout_below="#+id/interestsPrimary"
android:id="#+id/interestsSecondary"
android:layout_marginTop="5dp"
style="#style/LinearLayout.Interests">
<package_name.FontTextView
android:id="#+id/interest_4"
style="#style/TextView.Interest" />
<package_name.FontTextView
android:id="#+id/interest_5"
style="#style/TextView.Interest" />
You have to match the same package name as in your Project.
Try it and let me know if it worked for you
I'm trying to use TextInputLayout in my XML, and I'm meeting this error :
java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.jechange.moncompte/fr.jechange.moncompte.SignUpActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
I've imported the design library, and the support-v7-appcompat library. And I'm using the Theme.AppCompat.Light.NoActionBar theme.
The XML in which I'm using the Text Input Layout contains just something like that:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
style="#style/matchParent">
<android.support.design.widget.TextInputLayout
android:id="#+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
if you are calling layout(containg TextInputLayout) from activity then
nothing just use YouActivityClassName.this in place of getApplicationcontext or YourApplicationClassName.getcontext() or other where you are passing context
I had the same issue fixed here.
Make sure you don't have any other support library import v4 and v7. You can use only the design-support library. Also you should make sure your theme "matchParent" inherit from Theme.AppCompat for all the platform you trying to run.
My issue was only on Lollipop because of the values-21/style.xml.
Hope it will help.