我正在使用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
和旧的支持库。
我该如何完成?是否有android.arch.navigation:navigation-fragment
个等效的JetPack库?我找到了,但是什么也没找到。
谢谢。
更新:我运行了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
答案 0 :(得分:2)
添加此库:
implementation 'androidx.core:core:1.0.1'
更新:
并检查您的gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
答案 1 :(得分:0)
找到以下依赖项
com.android.support:support-compat:28.0.0
并仅替换为androidx.appcompat:appcompat:1.0.0
因为CoreComponentFactory
类在两个依赖项中都可用,所以这就是它作为重复类冲突的原因
androidx.core.app.CoreComponentFactory
android.support.v4.app.CoreComponentFactory