迁移到androidx后错误膨胀类androidx.constraintlayout.ConstraintLayout?

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

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

我刚刚通过Android Studio菜单选项Refactor - > Refactor to Androidx迁移到androidx ...

我收到以下错误:

android.view.InflateException:二进制XML文件行#2:二进制XML文件行#2:错误膨胀类androidx.constraintlayout.ConstraintLayout

有人有想法吗?

下面是堆栈跟踪:

2018-10-19 00:25:58.128 28131-28131 / com.midounoo.midounoo E / AndroidRuntime:FATAL EXCEPTION:main进程:com.midounoo.midounoo,PID:28131 java.lang.RuntimeException:无法启动活动ComponentInfo { com.midounoo.midounoo / com.midounoo.midounoo.Base.MainActivity}:android.view.InflateException:二进制XML文件行#2:二进制XML文件行#2:在android.app中输出类androidx.constraintlayout.ConstraintLayout时出错。 android.app.A活动中的ActivityThread.performLaunchActivityLaunchActivity(ActivityThread.java:2724)在Android.app.ActivityThread.H.handleMessage上的android.app.ActivityThread.-wrap12(ActivityThread.java)处于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789) ActivityThread.java:1527)在android.os.Looper.loop(Looper.java)的android.os.Handler.dispatchMessage(Handler.java:110)203)在android.app.ActivityThread.main(ActivityThread.java:6255)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java: 1063)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)引起:android.view.InflateException:二进制XML文件行#2:二进制XML文件行#2:错误膨胀类androidx.constraintlayout .ConstraintLayout引起:android.view.InflateException:二进制XML文件行#2:错误膨胀类androidx.constraintlayout.ConstraintLayout引起:java.lang.ClassNotFoundException:未在路径上找到类“androidx.constraintlayout.ConstraintLayout”: DexPathList [[zip文件“/data/app/com.midounoo.midounoo-2/base.apk”,zip文件“/data/app/com.midounoo。midounoo-2 / split_lib_dependencies_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2/split_lib_slice_0_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2/split_lib_slice_1_apk.apk“ ,zip文件“/data/app/com.midounoo.midounoo-2/split_lib_slice_2_apk.apk”,zip文件“/data/app/com.midounoo.midounoo-2/split_lib_slice_3_apk.apk”,zip文件“/ data / app /com.midounoo.midounoo-2/split_lib_slice_4_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2/split_lib_slice_5_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2 /split_lib_slice_6_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2/split_lib_slice_7_apk.apk“,zip文件”/data/app/com.midounoo.midounoo-2/split_lib_slice_8_apk.apk“,zip文件“/data/app/com.midounoo.midounoo-2/split_lib_slice_9_apk。在dalvik.system.BaseDexClassLoader.findClass上的apk“],nativeLibraryDirectories = [/ data / app / com.midounoo.midounoo-2 / lib / arm64,/ system / lib64,/ vendor / lib64,/ system / vendor / lib64]] (BaseDexClassLoader.java:56)java.lang.ClassLoader.loadClass(ClassLoader.java:380)at java.lang.ClassLoader.loadClass(ClassLoader.java:312)at android.view.LayoutInflater.createView(LayoutInflater.java: 609)在Android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)的android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787),android.view.LayoutInflater.inflate(LayoutInflater.java:495)。在androidx.appcompat.app.AppCompatDelegateImpl的android.view.LayoutInflater.inflate(LayoutInflater.java:377)中查看.LayoutInflater.inflate(LayoutInflater.java:426)。位于android.app.Activity的com.midounoo.midounoo.Base.MainActivity.onCreate(MainActivity.java:43)的androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)中的setContentView(AppCompatDelegateImpl.java:469) .performCreate(Activity.java:6666)在android.app.Anstrumentation.callActivityCenate(Instrumentation.java:1118)的android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)android.app.ActivityThread.handleLaunchActivity(ActivityThread。 java:2789)在Android.app.Handler.dispatchMessage(Handler.java:110)的android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1527)的android.app.ActivityThread.-wrap12(ActivityThread.java)在Android.app.AooTloread的android.os.Looper.loop(Looper.java:203)。main(ActivityThread.java:6255)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1063)

提问于
用户回答回答于

添加androidx.constraintlayout.ConstraintLayout到依赖项:

dependencies  {
    // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout
    implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}

存储库是mavenCentral()

用户回答回答于

布局xml文件中的问题

将此更改androidx.constraintlayout.ConstraintLayout 为线性布局检查您的日志

扫码关注云+社区

领取腾讯云代金券