0
我想用RxAndroid進行翻新,因此我導入瞭如下所示的所需依賴項。但WHN我運行應用程序時,我收到以下錯誤 :使用RxAndroid進行翻新時出現重複文件異常
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
File1: C:\Users\PC-Amryi\.gradle\caches\modules-2\files-2.1\io.reactivex\rxjava\1.1.9\e4362e62f1ba92e360b197d6d7ffae67e5ecae9a\rxjava-1.1.9.jar
File2: C:\Users\PC-Amryi\.gradle\caches\modules-2\files-2.1\io.reactivex.rxjava2\rxjava\2.0.0\5151c737c01616c372c3d00ab145868ede10e826\rxjava-2.0.0.jar
來解決這個問題,我試圖用不同的RxAndroid和RxJava庫如下:
//RxJava and RxAndroid
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.9'
//compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//compile 'io.reactivex.rxjava2:rxjava:2.0.1'
//compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
,但我仍然得到同樣的錯誤
請各位看看下面poted的gradle這個文件,請幫我解決這個問題
gradle這個:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.pc_amr.rxretrofit_1"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//to enable Java-8
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//RxJava and RxAndroid
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.9'
//compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//compile 'io.reactivex.rxjava2:rxjava:2.0.1'
//compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
//compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.solidfire.code.gson:gson:2.6.2'
compile 'com.google.code.gson:gson-parent:2.8.1'
compile 'com.solidfire.code.gson:gson-parent:2.6.2'
compile 'com.android.support:support-annotations:25.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
}