迁移到androidx后出错类android.support.design.widget.CoordinatorLayout时出错

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (4021)

我刚刚迁移到Androidx但迁移后,我收到以下错误:

引起:android.view.InflateException:二进制XML文件行#12:二进制XML文件行#2:错误膨胀类android.support.design.widget.CoordinatorLayout`

任何的想法?

堆栈跟踪:

 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'
} ```



提问于
用户回答回答于

1.如果布局包含:< android.support.design.widget.CoordinatorLayout

用以下内容代替: <androidx.coordinatorlayout.widget.CoordinatorLayout

2.如果布局包含:< android.support.design.widget.FloatingActionButton

用以下内容代替: <com.google.android.material.floatingactionbutton.FloatingActionButton

用户回答回答于

你有任何机会有一些遗忘的layout-land目录或什么?其中可能包含一些迁移过的XML文件。我刚刚发现这就是我项目中发生的事情。(也许在里面不一样falvor?)

扫码关注云+社区

领取腾讯云代金券