我正在使用 Jetpack 库开发 Android 应用程序。 我也想使用导航,以更酷的方式定义导航。为此,我包含(Android Studio 为我做的)依赖项:
implementation 'android.arch.navigation:navigation-fragment:1.0.0-beta02'
我正在使用 JetPack 库(别看我如何定义它们,它是有效的):
lifecycleVersion = '2.0.0'
loggingRetrofitVersion = "3.9.0"
butterKnife = "10.0.0"
kriptonVersion = "5.1.0-rc.3"
eventBusVersion = "3.1.1"
okHttpVersion="3.13.1"
kriptonVersion = "5.1.0-rc.3"
aboutlibrariesVersion = "6.1.1"
daggerVersion="2.21"
glideVersion="4.8.0"
// Testing
jUnitVersion = '4.12'
mockitoVersion = '2.13.+'
jacocoVersion = '0.7.9'
espressoVersion="3.1.0"
// Libraries android
appCompatVersion = '1.0.2'
supportAnnotationVersion="1.0.0"
multidexVersion = '2.0.0'
cardviewVersion="1.0.0"
constraintLayoutVersion="1.1.3"
coordinatorLayoutVersion="1.0.0"
recyclerViewVersion="1.0.0"
materialVersion="1.1.0-alpha03"
viewPagerVersion="1.0.0"
// Presentation
appDependencies = [
"androidx.appcompat:appcompat:$appCompatVersion",
"androidx.cardview:cardview:$cardviewVersion",
"androidx.constraintlayout:constraintlayout:$constraintLayoutVersion",
"androidx.coordinatorlayout:coordinatorlayout:$coordinatorLayoutVersion",
"androidx.recyclerview:recyclerview:$recyclerViewVersion",
"androidx.viewpager:viewpager:$viewPagerVersion",
"com.google.android.material:material:$materialVersion",
// ViewModel and LiveData
"androidx.lifecycle:lifecycle-livedata-core:$lifecycleVersion",
"androidx.lifecycle:lifecycle-runtime:$lifecycleVersion",
"androidx.lifecycle:lifecycle-extensions:$lifecycleVersion",
"androidx.lifecycle:lifecycle-extensions:2.1.0-alpha02",
"org.greenrobot:eventbus:$eventBusVersion",
"com.jakewharton:butterknife:$butterKnife",
"com.abubusoft:kripton-android-library:$kriptonVersion",
"com.squareup.okhttp3:logging-interceptor:$loggingRetrofitVersion",
"com.google.dagger:dagger:$daggerVersion",
"com.squareup.retrofit2:converter-scalars:2.5.0",
"io.reactivex:rxjava:1.1.8"
]
由于我包含了库导航,当我尝试构建项目时,我收到以下错误:
> Task :app:processDebugManifest FAILED
D:\mobile\my-project\app\src\main\AndroidManifest.xml:22:18-86 Error:
Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.1.0-alpha03] AndroidManifest.xml:22:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-99:19 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
好吧,我可以简单地添加新标签..但我想避免在我的项目中存在 androidx
和旧的支持库。
我怎样才能做到这一点? JetPack 是否有等效的 android.arch.navigation:navigation-fragment
库?我找到了,但没有找到任何东西。
提前谢谢您。
更新:我运行了 gradle 目标依赖项,结果是(对于特定库):
+--- android.arch.navigation:navigation-fragment:1.0.0-beta02
| +--- com.android.support:support-fragment:28.0.0
| | +--- com.android.support:support-compat:28.0.0
| | | +--- com.android.support:support-annotations:28.0.0
| | | +--- com.android.support:collections:28.0.0
| | | | \--- com.android.support:support-annotations:28.0.0
| | | +--- android.arch.lifecycle:runtime:1.1.1
| | | | +--- android.arch.lifecycle:common:1.1.1
| | | | | \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
| | | | +--- android.arch.core:common:1.1.1
| | | | | \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
| | | | \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
| | | \--- com.android.support:versionedparcelable:28.0.0
| | | +--- com.android.support:support-annotations:28.0.0
| | | \--- com.android.support:collections:28.0.0 (*)
| | +--- com.android.support:support-core-ui:28.0.0
| | | +--- com.android.support:support-annotations:28.0.0
| | | +--- com.android.support:support-compat:28.0.0 (*)
| | | +--- com.android.support:support-core-utils:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | +--- com.android.support:documentfile:28.0.0
| | | | | \--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:loader:28.0.0
| | | | | +--- com.android.support:support-annotations:28.0.0
| | | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | | +--- android.arch.lifecycle:livedata:1.1.1
| | | | | | +--- android.arch.core:runtime:1.1.1
| | | | | | | +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
| | | | | | | \--- android.arch.core:common:1.1.1 (*)
| | | | | | +--- android.arch.lifecycle:livedata-core:1.1.1
| | | | | | | +--- android.arch.lifecycle:common:1.1.1 (*)
| | | | | | | +--- android.arch.core:common:1.1.1 (*)
| | | | | | | \--- android.arch.core:runtime:1.1.1 (*)
| | | | | | \--- android.arch.core:common:1.1.1 (*)
| | | | | \--- android.arch.lifecycle:viewmodel:1.1.1
| | | | | \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
| | | | +--- com.android.support:localbroadcastmanager:28.0.0
| | | | | \--- com.android.support:support-annotations:28.0.0
| | | | \--- com.android.support:print:28.0.0
| | | | \--- com.android.support:support-annotations:28.0.0
| | | +--- com.android.support:customview:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | \--- com.android.support:support-compat:28.0.0 (*)
| | | +--- com.android.support:viewpager:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | \--- com.android.support:customview:28.0.0 (*)
| | | +--- com.android.support:coordinatorlayout:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | \--- com.android.support:customview:28.0.0 (*)
| | | +--- com.android.support:drawerlayout:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | \--- com.android.support:customview:28.0.0 (*)
| | | +--- com.android.support:slidingpanelayout:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | \--- com.android.support:customview:28.0.0 (*)
| | | +--- com.android.support:interpolator:28.0.0
| | | | \--- com.android.support:support-annotations:28.0.0
| | | +--- com.android.support:swiperefreshlayout:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | +--- com.android.support:support-compat:28.0.0 (*)
| | | | \--- com.android.support:interpolator:28.0.0 (*)
| | | +--- com.android.support:asynclayoutinflater:28.0.0
| | | | +--- com.android.support:support-annotations:28.0.0
| | | | \--- com.android.support:support-compat:28.0.0 (*)
| | | \--- com.android.support:cursoradapter:28.0.0
| | | \--- com.android.support:support-annotations:28.0.0
| | +--- com.android.support:support-core-utils:28.0.0 (*)
| | +--- com.android.support:support-annotations:28.0.0
| | +--- com.android.support:loader:28.0.0 (*)
| | \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
| \--- android.arch.navigation:navigation-runtime:1.0.0-beta02
| +--- com.android.support:support-core-utils:28.0.0 (*)
| \--- android.arch.navigation:navigation-common:1.0.0-beta02
| \--- com.android.support:support-compat:28.0.0 (*)
+--- androidx.core:core:1.0.1 -> 1.1.0-alpha03 (*)
+--- junit:junit:4.12
最佳答案
添加此库:
implementation 'androidx.core:core:1.0.1'
更新:
并检查你的 gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
关于android - 导航 fragment 与 JetPack 库的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54670522/