提问人:Dr Mido 提问时间:6/7/2021 更新时间:6/7/2021 访问量:136
从输入中找到 2 个文件,路径为“androidsupportmultidexversion,.txt”(.txt
2 files found with path 'androidsupportmultidexversion.txt' from inputs
问:
当我尝试构建或运行我的应用程序时,会发生此错误
> Task :app:mergeDebugJavaResource FAILED
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'androidsupportmultidexversion.txt' from inputs:
- C:\Users\User\.gradle\caches\transforms-2\files-2.1\eea432b5b906aa8ac69bbc0cbb8ebb90\multidex-2.0.1\jars\classes.jar
- C:\Users\User\.gradle\caches\transforms-2\files-2.1\da650fcfe296862d40a84f8e3b03a132\multidex-1.0.3\jars\classes.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
build.gradle 文件
plugins {
id 'com.android.application'
id("dagger.hilt.android.plugin")
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.mml.pokemon"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def room_version = "2.2.5"
def nav_version = "2.3.0-beta01"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.android.support:multidex:1.0.3'
// Hilt
implementation "com.google.dagger:hilt-android:2.36"
annotationProcessor 'com.google.dagger:hilt-android-compiler:2.36'
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0'
//RxJava
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.3'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0"
// ViewModel
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
// LiveData
implementation 'androidx.lifecycle:lifecycle-livedata:2.3.1'
// Room
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
// Navigation
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
//sdp
implementation 'com.intuit.sdp:sdp-android:1.0.6'
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
我从这个错误中了解到的是,这个路径中有 2 个版本的 multidex,为了解决这个问题,我尝试了以下方法:
- 从此路径“C:\Users\User.gradle\caches\transforms-2\files-2.1\da650fcfe296862d40a84f8e3b03a132\multidex-1.0.3\jars\classes.jar”中删除旧版本的MultiDex“并保留较新的版本。
- 像这样从这个答案中添加包选项
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
- 我还尝试从文件中删除multiDexEnabled true并像这样添加它
dependencies {
def multidex_version = "2.0.1"
implementation 'androidx.multidex:multidex:$multidex_version'
}
不幸的是,所有这些尝试都没有奏效
答: 暂无答案
评论
com.android.support:multidex:1.0.3