android-发现多个文件具有与操作系统无关的路径

我正在图书馆:

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

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

More than one file was found with OS independent path ‘META-INF/androidx.vectordrawable_vectordrawable.version’

摇篮:

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'

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

您正在使用许多较旧的支持库,这些库可能与Androidx库冲突.您可以查看Migrating to AndroidX文档,了解哪些支持库可以移至Androidx.

上一篇:AndroidX与DataBinding Android不兼容


下一篇:android-ConstraintLayout屏障在设计视图中不可见