Работаю с библиотекой:
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'
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.
Большое спасибо за ваш ответ, все сработало отлично, еще раз спасибо и обнимаю.