前提・実現したいこと
タイトルのエラーを解消したい。
エラーが発生した操作
BottomAppBar を実装するため、いくつかコードを追加したところエラー発生。コード詳細は、後述してます。
発生している問題・エラーメッセージ
Run した場合
More than one file was found with OS independent path 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'
####Buid した場合
AGPBI: {"kind":"error","text":"Program type already present: androidx.versionedparcelable.CustomVersionedParcelable","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/xxx/AndroidStudioProjects/xxx/app/build/intermediates/transforms/dexBuilder/debug/0.jar, もろもろ続く Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.versionedparcelable.CustomVersionedParcelable
該当のソースコード
app gradle
dependencies
にimplementation 'com.google.android.material:material:1.0.0'
を追加
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Other components and views --> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" app:fabSize="normal" android:src="@drawable/ic_add_white_24dp" app:layout_anchor="@id/bottom_app_bar"/> <com.google.android.material.bottomappbar.BottomAppBar android:id="@+id/bottom_app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:backgroundTint="@color/colorPrimary" app:fabAlignmentMode="end"/> </android.support.design.widget.CoordinatorLayout>
styles.xml
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
へ変更
試したこと
- Build > clean project
- Refactor > Migrate to AndroidX
app gradle へ追加
android.packagingOptions { exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version' }
上記を追加したところ、エラー内容が変化。同じくエラーのパスをexclude ~
で追加しても同様のエラーが続きました。
More than one file was found with OS independent path 'META-INF/androidx.customview_customview.version'
Google で検索したところ、ライブラリのバージョンが問題になっていそう、ということまでは、わかりましたが、知識不足からそれ以上進めなくなってしまいました。。
Android 開発が初心者のため、初歩的な内容かもしれません。必要な情報があれば、都度追記しますので、教えていただけるとうれしいです。どうぞよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー