找到多个具有独立于操作系统的路径的文件



我正在使用库:

implementation 'androidx.appcompat:appcompat:1.0.0-rc02'

我正在尝试集成com.google.android.material.bottomappbar.BottomAppBar,但当我运行应用程序时,它返回以下错误:

发现多个文件的操作系统独立路径为"META-INF/androidx.vectordrawable_vectordrawable.version">

Gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "gregorio.com.mx.ejemplo"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//Butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//Airbnb
implementation 'com.airbnb.android:lottie:2.5.4'
//Glide
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
//CircleImage
implementation 'de.hdodenhof:circleimageview:2.2.0'
//Volley
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.2'}

XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreen">

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:padding="16dp"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hola"
/>

</LinearLayout>

</androidx.core.widget.NestedScrollView>
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Ocultar/Mostrar FAB" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
style="@style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:hideOnScroll="true"

app:fabCradleMargin="12dp"
app:fabCradleVerticalOffset="12dp"
app:fabCradleRoundedCornerRadius="24dp"


app:backgroundTint="@color/design_default_color_primary"
app:fabAlignmentMode="center"
app:navigationIcon="@drawable/ic_menu" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"
app:backgroundTint="@color/design_default_color_primary_dark"
app:elevation="0dp"
app:layout_anchor="@id/bar" />

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cesarmanuel.com.mx.guanajuato">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString">
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" 
/>
</intent-filter>
</activity>
</application>

非常感谢,希望你能帮我解决问题。

您使用了两个不同但相关的appcompat版本,这导致了冲突错误。从您的应用程序级别build.gradle:

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'

您同时使用旧的support版本和新的androidx版本。两者都包含文件META-INF/androidx.vectordrawable_vectordrawable.version。使用其中一个,但不能同时使用。

您正在使用一些较旧的支持库,这些库可能与Androidx库冲突。您可以通过查看迁移到Androidx文档来查看哪些支持库可以移动到Androidx。

在android{}中转到您的Project/app/build.gradle

android { 
packagingOptions { 
pickFirst 'the/NameOfThe/lib.so' 
pickFirst '**/*.so' //if you dont know the name of the library
} 
}

相关内容

最新更新