Didn't find class "android.support.constraint.Barrier" - android

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.

Related

SnackbarContentLayout class not found after migration to AndroidX

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

Could Not Find Resource in Google Material Dependency When Using FloatingActionButton in Android 4.3.1

Android Version: 4.3.1
Device: Defy Mini
Receiving a crash report on Android 4.3.1 when trying to inflate a layout that contains a FloatingActionButton. This component is included in my project by importing the dependency com.google.android.material:material:1.0.0.
The important information from the crash report is the following.
Caused by android.content.res.Resources$NotFoundException
Resource ID #0x7f080110
I have searched online and the resource matching this is unlabeled
Here is how I include the FloatingActionButton in my xml layout.
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/fab_save"
app:layout_anchorGravity="center"
app:fabSize="mini"
app:layout_anchor="#+id/fab_controls"
app:srcCompat="#drawable/ic_menu_save"
app:backgroundTint="#color/whiteColor"
android:tint="#color/gpsBackground"
android:visibility="invisible"/>
Unsure how to proceed. Any pointers would be very helpful.

Didn't find class "androidx.constraintlayout.ConstraintLayout"

I am developing a library for Android, and this library has some activities with its layouts.
In the layout, I have the next code
...
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.floatingactionbutton.FloatingActionButton
...
I am using Androidx.
An I get the following error:
Error inflating class android.support.constraint.ConstraintLayout
The first attempt to solve this was to changeandroid.support.constraint.ConstraintLayout to androidx.constraintlayout.widget.ConstraintLayout
But when I do this I get the following error:
androidx.constraintlayout.widget.ConstraintLayout cannot be cast to
androidx.constraintlayout.widget.Group
So I try to change to androidx.constraintlayout.widget.Group
I get the following error:
androidx.constraintlayout.widget.Group cannot be cast to
android.view.ViewGroup
I did a refactor again to androidx and then I get the following error:
Didn't find class "androidx.constraintlayout.ConstraintLayout"
Any idea?
Thanks
Follow this steps
First add below dependencies in your Build.Gradle file
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Use this ConstraintLayout like this
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.constraintlayout.widget.ConstraintLayout>
Make sure you have correct imports of ConstraintLayout for in your activity if you have used
import androidx.constraintlayout.widget.ConstraintLayout

Material chip crashing app. Cannot inflate xml

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"

Constraint layout can not be rendered in Android studio

Coding a constraint layout:
<View
android:id="#+id/divider"
style="#style/divider_style"
android:layout_width="0dp"
swedbank:layout_constraintBottom_toBottomOf="parent"
swedbank:layout_constraintLeft_toLeftOf="parent" />
<ImageView
android:id="#+id/some_image"
style="#style/some_style"
swedbank:layout_constraintBottom_toBottomOf="#+id/divider" <!-- This '+' -->
swedbank:layout_constraintRight_toRightOf="parent"
swedbank:layout_constraintTop_toTopOf="#+id/divider" /> <!-- This '+' -->
See the comments: the plusses on those lines must be there for the android studio layout renderer to work. without them you get:
Couldn't resolve resource #id/divider Tip: Try to refresh the layout.
I always thought #+id/ was for the first time you defined an id?
I've experienced IDE problems if I use +'es everywhere some years ago: With goto-definition the IDE would not know which id to go to
Tested on Android studio 2.3.3 and 3.0.1
Seeing as the auto-complete gives you plusses everywhere should i just go with that?
Try adding this to your dependencies section in the gradle
compile 'com.android.support.constraint:constraint-layout:1.0.2'

Categories

Resources