在genymotion设备中运行时,膨胀类androidx.constraintlayout.widget.ConstraintLayout时出错

时间:2019-05-31 13:23:58

标签: android

当我在genymotion虚拟设备中运行我的应用程序时发生错误并且我的应用程序崩溃了。错误是:

5-31 13:15:18.838 1205-1205/com.mypackage E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage/com.mypackage.StarterActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout

我的应用gradle依赖项:

 implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02'
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'

注意:我的应用在真实设备上可以正常运行。

1 个答案:

答案 0 :(得分:1)

确保约束布局已更新为最新版本:

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

并替换您的xml标记名称

<androidx.constraintlayout.ConstraintLayout>

使用

<androidx.constraintlayout.widget.ConstraintLayout>