迁移到Jetpack / AndroidX后出现InflateException

问题描述 投票:2回答:1

通过Android Studio迁移到Jetpack,尝试运行应用程序但在应用程序关闭时继续获取以下跟踪:

引起:android.view.InflateException:二进制XML文件行#11:错误膨胀类com.google.android.material.floatingactionbutton.FloatingActionButton

这是xml:

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    style="@style/Widget.MaterialComponents.FloatingActionButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_marginRight="10px"
    android:layout_marginBottom="200px"
    android:src="@drawable/ic_plus"
    android:tint="#FFF"
    app:fabSize="mini" />

这是我的依赖项:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
    implementation 'com.google.android.material:material:1.1.0-alpha04'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
    implementation 'com.squareup.picasso:picasso:2.71828'
    compileOnly 'org.projectlombok:lombok:1.18.6'
    annotationProcessor 'org.projectlombok:lombok:1.18.6'
    implementation 'com.ramotion.fluidslider:fluid-slider:0.2.0'
    implementation 'com.uber.sdk:rides-android:0.10.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha03'
    implementation 'androidx.cardview:cardview:1.0.0'

    def lifecycle_version = '2.1.0-alpha03'

    // ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation 'com.google.maps.android:android-maps-utils:0.5+'
    implementation 'com.shawnlin:number-picker:2.4.8'
}
android android-layout androidx android-jetpack
1个回答
4
投票

我在我的示例项目中尝试了XML。有用。但是你的主题应该从Theme.MaterialComponents.blabla....扩展

喜欢这个xml块

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
© www.soinside.com 2019 - 2024. All rights reserved.