動画を参考にrealmの使い方を勉強していたのですが、エラーが出てしまい他サイトを参考にしても直りません。助けてくださる方いらっしゃいましたらよろしくお願いいたします。
error
1AGPBI: {"kind":"error","text":"Type androidx.activity.R$layout is defined multiple times: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex, C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\c71e33c820d6c2e1e90ca4403d011c9c6ec504582e69b54d7412a5d84dc8430a_0.jar:classes.dex","sources":[{"file":"C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex"}],"tool":"D8"} 2com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 3Type androidx.activity.R$layout is defined multiple times: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex, C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\c71e33c820d6c2e1e90ca4403d011c9c6ec504582e69b54d7412a5d84dc8430a_0.jar:classes.dex 4Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. 5 at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:132) 6 at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:119) 7 at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102) 8 at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:432) 9 at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:242) 10 at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:57) 11 at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) 12 at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67) 13 at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63) 14 at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97) 15 at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63) 16 at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) 17 at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) 18 at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409) 19 at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399) 20 at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157) 21 at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242) 22 at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150) 23 at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94) 24 at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36) 25 at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) 26 at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60) 27 at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200) 28 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 29 at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215) 30 at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164) 31 at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131) 32 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 33 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 34 at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) 35 at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) 36 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 37 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 38 at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) 39 at java.lang.Thread.run(Thread.java:748) 40Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex 41 at Version.fakeStackEntry(Version_2.1.75.java:0) 42 at com.android.tools.r8.utils.Y.a(SourceFile:78) 43 at com.android.tools.r8.D8.run(D8.java:11) 44 at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117) 45 ... 33 more 46Caused by: com.android.tools.r8.utils.b: Type androidx.activity.R$layout is defined multiple times: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex, C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\c71e33c820d6c2e1e90ca4403d011c9c6ec504582e69b54d7412a5d84dc8430a_0.jar:classes.dex 47 at com.android.tools.r8.utils.T0.error(SourceFile:1) 48 at com.android.tools.r8.utils.T0.a(SourceFile:2) 49 at com.android.tools.r8.utils.R0.b(SourceFile:6) 50 at com.android.tools.r8.utils.R0.a(SourceFile:24) 51 at com.android.tools.r8.utils.R0.a(SourceFile:10) 52 at java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:1990) 53 at com.android.tools.r8.utils.R0.a(SourceFile:6) 54 at com.android.tools.r8.graph.Q0$c.f(SourceFile:3) 55 at com.android.tools.r8.dex.a.a(SourceFile:298) 56 at com.android.tools.r8.dex.a.a(SourceFile:226) 57 at com.android.tools.r8.D8.d(D8.java:6) 58 at com.android.tools.r8.D8.b(D8.java:1) 59 at com.android.tools.r8.utils.Y.a(SourceFile:36) 60 ... 35 more 61 62 63Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex 64 65Caused by: com.android.tools.r8.utils.b: Type androidx.activity.R$layout is defined multiple times: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex, C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\c71e33c820d6c2e1e90ca4403d011c9c6ec504582e69b54d7412a5d84dc8430a_0.jar:classes.dex 66 67Execution failed for task ':app:mergeProjectDexDebug'. 68> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 69 > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 70 Type androidx.activity.R$layout is defined multiple times: C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\androidx\activity\R$layout.dex, C:\Users\user\AndroidStudioProjects\TodoList\app\build\intermediates\project_dex_archive\debug\out\c71e33c820d6c2e1e90ca4403d011c9c6ec504582e69b54d7412a5d84dc8430a_0.jar:classes.dex 71 Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. 72 73
buildgradle
1plugins { 2 id 'com.android.application' 3 id 'realm-android' 4} 5 6 7android { 8 compileSdkVersion 30 9 buildToolsVersion "30.0.2" 10 11 defaultConfig { 12 applicationId "com.example.todolist" 13 minSdkVersion 16 14 targetSdkVersion 30 15 versionCode 1 16 versionName "1.0" 17 18 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 multiDexEnabled true 20 } 21 22 buildTypes { 23 release { 24 minifyEnabled false 25 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 } 27 } 28 compileOptions { 29 sourceCompatibility JavaVersion.VERSION_1_8 30 targetCompatibility JavaVersion.VERSION_1_8 31 } 32} 33 34dependencies { 35 36 implementation 'androidx.appcompat:appcompat:1.2.0' 37 implementation 'com.google.android.material:material:1.1.0' 38 implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 39 implementation 'androidx.navigation:navigation-fragment:2.2.2' 40 implementation 'androidx.navigation:navigation-ui:2.2.2' 41 testImplementation 'junit:junit:4.+' 42 androidTestImplementation 'androidx.test.ext:junit:1.1.2' 43 androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 44 implementation 'io.realm:android-adapters:1.0.1' 45}
buildgradle
1// Top-level build file where you can add configuration options common to all sub-projects/modules. 2buildscript { 3 repositories { 4 google() 5 jcenter() 6 } 7 dependencies { 8 classpath "com.android.tools.build:gradle:4.1.1" 9 classpath "io.realm:realm-gradle-plugin:10.0.1" 10 11 // NOTE: Do not place your application dependencies here; they belong 12 // in the individual module build.gradle files 13 } 14} 15 16allprojects { 17 repositories { 18 google() 19 jcenter() 20 } 21} 22 23task clean(type: Delete) { 24 delete rootProject.buildDir 25}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。