从 RxAndroid 1.x 迁移到 2.x(包括 RxJava)
Migrate from RxAndroid 1.x to 2.x (RxJava included)
我有一个项目 运行 RxAndroid 1.x(一切正常)。
我正在尝试迁移到 2.x 版本。
我的 gradle 文件:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
//compile 'io.reactivex:rxandroid:1.2.1'
//compile 'io.reactivex:rxjava:1.2.1'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
}
我有这个错误:
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: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.0/5151c737c01616c372c3d00ab145868ede10e826/rxjava-2.0.0.jar
File2: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.0/748f0546d5c3c27f1aef07270ffea0c45f0c42a4/rxjava-1.1.0.jar
为什么要添加 RxJava 1.1.0?
我可以排除 rxjava.properties 但我想了解错误。我已清理项目并使缓存无效,但错误仍然存在。
看图:
谢谢
您可以通过 运行 命令 ./gradlew :app:dependencies
在项目的根目录中找到可能包含 RxJava 1.1.0 的库,其中 app 是您包含这些依赖项的模块的名称来自.
在你的情况下,我建议违规项目是:com.jakewharton.rxbinding:rxbinding:0.4.0
只是想 follow-up 解决这个问题。 RxBinding 1.0.0 已经发布,从那时起它应该与 RxJava2 兼容,但是它仍然导入旧版本的 RxJava,这导致了这个问题询问的相同问题。为了解决这个问题,只需将以下内容添加到 android.
下的 gradle 构建脚本中
android {
...
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
要解决此问题,现在您可以将 RxBinding 和 Retrofit Adapter 更新到版本 2。
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
我有一个项目 运行 RxAndroid 1.x(一切正常)。 我正在尝试迁移到 2.x 版本。
我的 gradle 文件:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
//compile 'io.reactivex:rxandroid:1.2.1'
//compile 'io.reactivex:rxjava:1.2.1'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0-RC1'
}
我有这个错误:
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: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.0/5151c737c01616c372c3d00ab145868ede10e826/rxjava-2.0.0.jar
File2: /Users/agustin/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.0/748f0546d5c3c27f1aef07270ffea0c45f0c42a4/rxjava-1.1.0.jar
为什么要添加 RxJava 1.1.0?
我可以排除 rxjava.properties 但我想了解错误。我已清理项目并使缓存无效,但错误仍然存在。
看图:
谢谢
您可以通过 运行 命令 ./gradlew :app:dependencies
在项目的根目录中找到可能包含 RxJava 1.1.0 的库,其中 app 是您包含这些依赖项的模块的名称来自.
在你的情况下,我建议违规项目是:com.jakewharton.rxbinding:rxbinding:0.4.0
只是想 follow-up 解决这个问题。 RxBinding 1.0.0 已经发布,从那时起它应该与 RxJava2 兼容,但是它仍然导入旧版本的 RxJava,这导致了这个问题询问的相同问题。为了解决这个问题,只需将以下内容添加到 android.
下的 gradle 构建脚本中android {
...
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
要解决此问题,现在您可以将 RxBinding 和 Retrofit Adapter 更新到版本 2。
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'