1

我为Motion Layout添加了库

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'

但是MotionLayout在布局文件中添加它无法识别布局。

Error inflating class android.support.constraint.motion.MotionLayout
4

2 回答 2

3

您正在导入 AndroidX/JetPack 依赖项,但使用对 MotionLayout 的旧引用。MotionLayout 类现在位于此处:

androidx.constraintlayout.motion.widget.MotionLayout

使用gradlew clean以及清理缓存进行干净的构建:)

于 2018-12-29T14:53:44.437 回答
1

我也面临这个问题。我无法在动态布局的预览屏幕中看到布局设计。

我的应用程序级别的 gradle 依赖项是:

implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'

布局文件是:<android.support.constraint.motion.MotionLayout ... />

当我将其更改为:androidx.constraintlayout.motion.widget.MotionLayout它工作正常。

于 2019-03-17T01:44:21.273 回答