我想使用 AndroidX Jetpack 库创建一个 Android 项目。但是这个库(导航)在 androidx 包中还没有。
我的 gradle 依赖项
def lifecycle_version = "2.0.0-alpha1"
def room_version = "2.0.0-alpha1"
def nav_version = "1.0.0-alpha01"
def mat_version = "1.0.0-alpha1"
// Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
// Room
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"
// Navigation
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
androidTestImplementation "android.arch.navigation:navigation-testing-ktx:$nav_version"
// Material Design
// implementation "com.google.android.material:material:$mat_version"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
我也有compileSdkVersion 'android-P'
但是当我想启动应用程序时,我得到了这个错误
Error: Program type already present: android.support.v4.app.INotificationSideChannel
我经常Clean Project
尝试Rebuild Project
在我的 gradle.properties
android.enableJetifier=false
android.useAndroidX=true
如果我设置enableJetifier
为 true 整个 android.support v4 库就会丢失,并且导航也不起作用,因为 android.support.v4.Fragment 丢失(和其他东西)。