在使用Android Studio将我的项目迁移到AndroidX
后(手动修复了许多导入错误),我没有编译错误,但当应用程序启动时,会崩溃并显示:
Error inflating class android.support.design.widget.AppBarLayout
。
布局文件中的有问题的行是:<android.support.design.widget.AppBarLayout
我的build.gradle
依赖项如下:
dependencies {
def lifecycle_version = '2.1.0-alpha02'
// used below--will be different for androidx (migrated 2019-02-04)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
// Relay class
implementation 'com.jakewharton.rx2:replaying-share:2.1.0'
// ReplayingShare
implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
// RxBinding
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" // see def above
// includes ViewModel and LiveData
implementation 'org.apache.commons:commons-lang3:3.8.1'
// for tuples like Triple
implementation 'com.androidplot:androidplot-core:1.5.6'
// AndroidPlot
}
我猜我错过了什么,但找不到是什么。
android.support.design.widget.AppBarLayout
并将其替换为com.google.android.material.appbar.AppBarLayout
,然后进行清理构建! - makata