Migrate from RxAndroid 1.x to 2.x (RxJava included) - android

I have a project running RxAndroid 1.x (everythings works).
I am trying to migrate to 2.x version.
My gradle file:
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'
}
I have this error:
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
Why RxJava 1.1.0 is added?
I can exclude the rxjava.properties but I would like to understand the error. I have cleaned the project and invalidated the cache but the error persists.
Look the picture:
Thanks

Just wanted to follow-up with a solution to this problem. RxBinding 1.0.0 has been released and from this point on it should be compatible with RxJava2, however it still imports an older version of RxJava which results in the same issue this question asks about. In order to fix the problem simply add the following to your gradle build scrip under android.
android {
...
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}

To fix this, now you can update the RxBinding and Retrofit Adapter to version to 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'

You can find out what libraries may be including RxJava 1.1.0 by running the command ./gradlew :app:dependencies in the root of your project where app is the name of the module you are including these dependencies from.
In your case I'd suggest the offending item is: com.jakewharton.rxbinding:rxbinding:0.4.0

Related

ZipException: duplicate entry: com/android/volley/AuthFailureError

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/android/volley/AuthFailureError.class
and this is my gradle build file:
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:appcompat-v7:25.3.1'
//compile 'com.facebook.android:facebook-android-sdk:4.14.0'
compile project(path: ':linkedin-sdk')
// compile 'com.mcxiaoke.volley:library-aar:1.0.0'
// compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-core-utils:25.3.1'
compile 'com.google.android.gms:play-services-maps:9.0.1'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
testCompile 'junit:junit:4.12'
}
The app works fine with the new version of the API.
But it has the problem with older versions of the API.
You seem to be confused about how to get Volley in your app
// compile 'com.android.volley:volley:1.0.0'
// compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Those last two are deprecated. The first line is correct.
https://developer.android.com/training/volley/index.html
And you need to remove any Volley related files from the libs directory, plus make sure LinkedIn library also isn't using volley
I don't see why you need it though when you have Okhttp for http calls and Glide and Picasso for image loading
Related errors will arise from mixing 25.3.1, 23.0.1, 23.1.1, and 25.1.1 support libraries. Those all need to be the exact same
multiDexEnabled true
Add above line into your build.gradle file in defaultConfig like this:
defaultConfig{
multiDexEnabled true
}
You can test putting this on root of directory in the Terminal
./gradlew clean

Cannot resolve error in Firebase Chat application

Im trying chat application using firebase. Im getting following error which could nit resolve myself,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzble.class
I have mentioned below my gradle file
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.google.firebase:firebase-core:10.2.4'
compile 'com.android.support:design:25.3.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.google.firebase:firebase-auth:10.2.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
FirebaseUI has transitive dependencies on a number of the Firebase libraries. You must specify a version of FirebaseUI that is compatible with the Firebase libraries you are using. The table of compatible versions is listed in the FirebaseUI documentation. The most recent FirebaseUI version is 1.2.0, which works with library version 10.2.0. A version of FirebaseUI for Firebase libs 10.2.4 and 10.2.6 has not been released.
The safe change is:
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
You could try 1.2.0 with 10.2.4 or 10.2.6, but may encounter the same problem you are seeing now.

Braintree Excluding Library from Gradle

I have used following dependency in my Android Studio gradle.
dependencies {
compile project(':facebookSDK')
compile project(':wheel')
compile project(':viewPagerLibrary')
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'io.card:android-sdk:5.0.0'
compile files('libs/acra-4.5.0.jar')
compile files('libs/analytics-3.4.0.jar')
compile files('libs/androidasync-1.3.8.jar')
compile files('libs/crashlytics.jar')
compile files('libs/CWAC-Adapter.jar')
compile files('libs/eventbus-2.2.0.jar')
compile files('libs/fastjson-1.1.6.jar')
compile files('libs/gradle-wrapper.jar')
compile files('libs/ion-1.3.8.jar')
compile files('libs/localytics.jar')
compile files('libs/nineoldandroids.jar')
compile files('libs/parse-1.3.0.jar')
compile files('libs/socialauth-4.4.jar')
compile files('libs/universal-image-loader-1.9.0.jar')
}
Now I need to implement Braintree Gradle dependency
compile 'com.braintreepayments.api:braintree:1.+'
But sometimes it show me some other error sometime its shows me java.exe finished with non-zero exit value 3.
I want to use this braintree dependency for payment options please help me out how can i use it without error with the current dependency.
Thanks a lot for solving my problem in advance.
The Braintree Android library depends on GSON version 2.2.4 or higher.. It looks like you're currently depending on version 2.1.0. Upgrading your dependency to 2.2.+ should satisfy Braintree's and allow installation.
If you do run into further problems, Braintree's support can help, via email at support#braintreepayments.com or phone at 877.434.2894.

Gradle Google Play Services gms module error

I'm trying to build my Android Studio project with gradle. I added a compile rule as follows:
compile 'com.google.android.gms:play-services:6.5.87'
However it gives the following error:
Error:Module version com.google.android.gms:play-services:6.5.87 depends on libraries but is not a library itself
I have tried changing version and excluding support-v4 module, as mentioned here:
Crouton depends on libraries but is not a library itself
But I cannot solve the error.
Any help would be appreciated.
EDIT: Here is my dependency list from my build.gradle file:
dependencies {
// compile project(':library')
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: 'org.apache.httpcomponents:httpclient'
}
}

Multi dex files define Lcom/google/gdata/util/common/base/Escaper

Multi dex files define Lcom/google/gdata/util/common/base/Escaper
I am stuck with the above error. The error ocured after i have added a dependency to the UserVoice SDK
compile 'com.uservoice:uservoice-android-sdk:+'
since i added this dependency i am unable to run my Android project.
I have read about the jarjar command could probably solve this issue. But since the dependency are .aar librararies i do not know what could be the possible solution
any help is greatly appreciated
List of other depedencies:
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.1.0#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
compile 'com.squareup.retrofit:retrofit:1.7.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.melnykov:floatingactionbutton:1.0.5'
compile 'com.balysv.materialmenu:material-menu-abc:1.+'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5#aar'
compile 'com.facebook.android:facebook-android-sdk:3.20.0'
compile 'com.joanzapata.android:android-iconify:1.0.8'
compile 'com.squareup:otto:1.3.5'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
Gradle depdencies pastebin: http://pastebin.com/0m6b8Wyi
The problem you are having is caused by the fact that you have two dependencies that include the Escaper class. These are most likely dependencies of your dependencies so it's not obvious which one includes that class. You can be sure that com.uservoice:uservoice-android-sdk:+ includes the class Escaper as that is when your error occurs.
You can fix this problem by excluding the dependency from one of your compile dependencies. Take a look at the Gradle docs and scroll down to where it talks about "Excluding transitive dependencies". One thing to be careful of is the fact that the dependencies might be different versions but contain the same class. You should confirm that both libraries will work with the same version of the Escaper class.

Categories

Resources