I just made a migration to Androidx but after the migration, I'm getting the following error:
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout`
Any idea?
Stacktrace:
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ir.bijac.com.bijac.BaseActivity.onCreate(BaseActivity.java:43)
at ir.bijac.com.bijac.TestActivity.onCreate(TestActivity.java:22)
compileSdkVersion 28
minSdkVersion 18
targetSdkVersion 28
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
} ```
I had a similar experience after migrating to Androidx. I resolved the issue following these steps: [1] Ensure that the layout file uses this
<androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
[2] Follow this step if Android studio did not change the support libraries imports after migration to Androidx.
Go to the class file(java or kt), DELETE all imports related to the former libraries and allow Android Studio to import the appropriate Androidx libraries. Do these for all other migration issues.
This is what your dependencies should look like:
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.drawerlayout:drawerlayout:1.0.0' //DrawerLayout
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0' //androidx AppBarLayout, CollapsingToolbarLayout etc.
implementation 'androidx.webkit:webkit:1.0.0' //androidx webview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With