我试图在项目中添加材料设计组件这是从Unity为android导出的。(Unity在:unityLibrary模块的库文件夹中为依赖项添加aar文件)
问题是材料设计依赖
implementation ('com.google.android.material:material:1.4.0')
尝试添加android .{…}依赖项
// dependency already present
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'androidx.arch.core.core-runtime-2.0.0', ext:'aar')
implementation(name: 'androidx.asynclayoutinflater.asynclayoutinflater-1.0.0', ext:'aar')
implementation(name: 'androidx.coordinatorlayout.coordinatorlayout-1.0.0', ext:'aar')
implementation(name: 'androidx.core.core-1.3.2', ext:'aar')
implementation(name: 'androidx.cursoradapter.cursoradapter-1.0.0', ext:'aar')
implementation(name: 'androidx.customview.customview-1.0.0', ext:'aar')
implementation(name: 'androidx.documentfile.documentfile-1.0.0', ext:'aar')
implementation(name: 'androidx.drawerlayout.drawerlayout-1.0.0', ext:'aar')
implementation(name: 'androidx.exifinterface.exifinterface-1.3.0', ext:'aar')
implementation(name: 'androidx.fragment.fragment-1.0.0', ext:'aar')
implementation(name: 'androidx.interpolator.interpolator-1.0.0', ext:'aar')
implementation(name: 'androidx.legacy.legacy-support-core-ui-1.0.0', ext:'aar')
implementation(name: 'androidx.legacy.legacy-support-core-utils-1.0.0', ext:'aar')
implementation(name: 'androidx.lifecycle.lifecycle-livedata-2.0.0', ext:'aar')
implementation(name: 'androidx.lifecycle.lifecycle-livedata-core-2.0.0', ext:'aar')
implementation(name: 'androidx.lifecycle.lifecycle-runtime-2.0.0', ext:'aar')
implementation(name: 'androidx.lifecycle.lifecycle-viewmodel-2.0.0', ext:'aar')
implementation(name: 'androidx.loader.loader-1.0.0', ext:'aar')
implementation(name: 'androidx.localbroadcastmanager.localbroadcastmanager-1.0.0', ext:'aar')
implementation(name: 'androidx.print.print-1.0.0', ext:'aar')
implementation(name: 'androidx.slidingpanelayout.slidingpanelayout-1.0.0', ext:'aar')
implementation(name: 'androidx.swiperefreshlayout.swiperefreshlayout-1.0.0', ext:'aar')
implementation(name: 'androidx.versionedparcelable.versionedparcelable-1.1.0', ext:'aar')
implementation(name: 'androidx.viewpager.viewpager-1.0.0', ext:'aar')
implementation project('FirebaseApp.androidlib')
implementation project('FirebaseCrashlytics.androidlib')
// Material Design adds androidx.{..} dependency with other version
implementation ('com.google.android.material:material:1.4.0')
并给出错误
Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules core-1.5.0-runtime.jar (androidx.core:core:1.5.0) and jetified-androidx.core.core-1.3.2-runtime.jar (:androidx.core.core-1.3.2:)
Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.5.0-runtime.jar (androidx.core:core:1.5.0) and jetified-androidx.core.core-1.3.2-runtime.jar (:androidx.core.core-1.3.2:)
Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.5.0-runtime.jar (androidx.core:core:1.5.0) and jetified-androidx.core.core-1.3.2-runtime.jar (:androidx.core.core-1.3.2:)
Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.5.0-runtime.jar (androidx.core:core:1.5.0) and jetified-androidx.core.core-1.3.2-runtime.jar (:androidx.core.core-1.3.2:) .......... and so on ..........
Go to the documentation to learn how to Fix dependency resolution errors.
所以,我试图排除androidx依赖使用exclude关键字
// Material Design
implementation ('com.google.android.material:material:1.4.0') {
exclude module: 'androidx'
}
但什么也没发生😔.
请帮助。🛐
您没有正确地排除该模块。
来自gradle示例:
implementation('commons-beanutils:commons-beanutils:1.9.4') {
exclude group: 'commons-collections', module: 'commons-collections'
}
在你的情况下,排除androidx.core:core:1.5.0
,我认为你需要:
implementation ('com.google.android.material:material:1.4.0') {
exclude group: 'androidx.core', module: 'core'
}