Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: androidx/core/view/ViewCompat when using FlexboxLayout

I'm using FlexboxLayout

Added below dependency in build.gradle of FlexboxLayout

dependencies {
    implementation 'com.google.android:flexbox:1.1.0'
}

myLayout

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">



</com.google.android.flexbox.FlexboxLayout>

I'm getting below error Error ScreenShot

java.lang.NoClassDefFoundError: androidx/core/view/ViewCompat
    at com.google.android.flexbox.FlexboxLayout.onLayout_Original(FlexboxLayout.java:565)
    at com.google.android.flexbox.FlexboxLayout.onLayout(FlexboxLayout.java)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.support.v7.widget.ActionBarOverlayLayout.onLayout_Original(ActionBarOverlayLayout.java:444)
    at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
    at android.view.View.layout_Original(View.java:20672)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:20658)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:348)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:450)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:590)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

How can i solve this issue

Thanks in advance. Your efforts will be appreciated.

like image 527
Goku Avatar asked Oct 24 '18 09:10

Goku


1 Answers

Solution is here

FlexboxLayout 1.1.0, the library is expected to use with AndroidX.

If you want to use 1.1.0 and above than migrate to AndroidX

For AndroidX use this

dependencies {
    implementation 'com.google.android:flexbox:1.1.0'
}

For com.android.support:appcompat

dependencies {
    implementation 'com.google.android:flexbox:1.0.0'
}

For more information please check FlexboxLayout Hope this help others

like image 191
Goku Avatar answered Nov 12 '22 07:11

Goku