Closed theshapguy closed 9 years ago
Do I have to wait till Digits Updates its module to Retrofit 2 or is there any other options to use them both together.
Yeah, unfortunately you either have to wait until they update their library to work with v2, or they need to be shading their Retrofit dependency so as not to cause conflicts like this.
The alternative is to ship Retrofit in a new package name which sounds appealing to people which have this happen, but is fraught with its own problems that I'm not too fond of.
A slightly hacky workaround (that I don't have a working example of off-hand) would be to create an empty library module in your project which depends on the Digits SDK. Then use either ProGuard or jarjar to move the Retrofit v1 package to something like retrofit1.*
or com.digits.sdk.internal.retrofit.*
. In your application you would then depend on that library module instead of the Digits SDK directly.
The Fabric team is aware of this issue and we will update retrofit to 2.0.0 once is final. Thanks for reporting this @TheShapGuy
@rallat please shade Retrofit (and other significant dependencies), if you switch to Retrofit v2 without shading — those who still use 1.9 in their apps won't be able to use new versions of your tools.
Conversely, if every library that wants to use Rertofit shades it, that's a ton of wasted APK size and methods towards the count.
Any news?
The same question :+1:
same thing with zendesk
Just stepped on this issue too...
Alright... 4 hours later, here's the fix. I've repackaged digits, twitter-core and retrofit 1.8 with jarjar to fix the package clash. You can find here a zip file with repackaged digits-1.9.1.aar
, fabric-1.3.7.aar
, retrofit-1.8.0.jar
and twitter-core-1.6.1.aar
to use retrofit1
package instead of retrofit
.
Here are the rough steps for reference (you don't need to do this, just download the zip file above):
rule retrofit.** retrofit1.@1
on digits, twitter-core classes.jar
and retrofit-1.8.0.jar
classes.jar
with the jarjar'ed ones and re-zip both directories (create zip file, then rename file extension to aar)libs
directoryNow manually add dependencies to aar files (you need to do this):
project/build.gradle
// Workaround for digits still depending on Retrofit 1.8.0
// Revert once that's upgraded to 2.0.0
compile 'com.google.code.gson:gson:2.4'
compile 'com.digits.sdk.android:digits:1.9.1@aar'
compile 'io.fabric.sdk.android:fabric:1.3.7@aar'
compile 'com.twitter.sdk.android:twitter-core:1.6.1@aar'
compile(files('libs/retrofit-1.8.0.jar'))
root-level build.gradle
allprojects {
repositories {
// this tells gradle to read the aar files from the libs directory
// make sure you don't have maven { url 'https://maven.fabric.io/public' } here, since
// you want to grab the files specifically from the libs folder and not from maven
flatDir { dirs 'libs' }
}
}
You'll also need this since you're depending both on retrofit 1.x and 2.x:
android {
packagingOptions {
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.properties'
exclude 'META-INF/maven/com.squareup.retrofit/retrofit/pom.xml'
}
}
That should be it.
@felipecsl I managed to get it up an running with your proposed solution, but when I try to do a release build I fails with:
Unable to compute hash of ..\release\classes.jar
I'm guessing this has something to do with the Proguard configuration, but simply adding retorfit1 instead of retorfit to the rules doesn't seem to work.
Any help would be appreciated :)
Is there any update on this issue please.
@guptavps this will be "automatically" fixed in the final release with the new Java Interoperability Policy for Major Version Updates
. You can read more about it at the @JakeWharton blog: http://jakewharton.com/java-interoperability-policy-for-major-version-updates/
thanks for the update. Is there any date published for this. I have already used Retrofit 2.0 beta in my project and wanted to use Digits now for user login which i can't....
Date: Mon, 28 Dec 2015 07:53:04 -0800 From: notifications@github.com To: retrofit@noreply.github.com CC: guptavps@hotmail.com Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps this will be automatically fixed in the final release with the new Java Interoperability Policy for Major Version Updates. You can read more here: http://jakewharton.com/java-interoperability-policy-for-major-version-updates/
— Reply to this email directly or view it on GitHub.
@guptavps See #1209 and #1342. Retrofit2 now uses new package name retrofit2
and conflicts has been solved.
Sorry for being novice, can you please tell me the steps to follow to avoid the conflict and error please...
Date: Mon, 28 Dec 2015 22:23:19 -0800 From: notifications@github.com To: retrofit@noreply.github.com CC: guptavps@hotmail.com Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps See #1209 and #1342. Retrofit2 now uses new package name retrofit2 and conflicts has been solved.
— Reply to this email directly or view it on GitHub.
I am trying to use Retrofit 2.0 beta with dependency compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' and i also have Fabric digits as followscompile('com.digits.sdk.android:digits:1.9.2@aar') { transitive = true; }
When i try to run digits code, it says RestAdapter could not be found. What change should i make please. From: guptavps@hotmail.com To: reply@reply.github.com; retrofit@noreply.github.com Subject: RE: [retrofit] Library Using Older Version of Retrofit (#1152) Date: Tue, 29 Dec 2015 06:56:42 +0000
Sorry for being novice, can you please tell me the steps to follow to avoid the conflict and error please...
Date: Mon, 28 Dec 2015 22:23:19 -0800 From: notifications@github.com To: retrofit@noreply.github.com CC: guptavps@hotmail.com Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps See #1209 and #1342. Retrofit2 now uses new package name retrofit2 and conflicts has been solved.
— Reply to this email directly or view it on GitHub.
You need to use the 2.0.0-SNAPSHOT until there is another release. 2.0.0-beta2 does not contain the package name change.
On Tue, Dec 29, 2015 at 1:59 AM guptavps notifications@github.com wrote:
I am trying to use Retrofit 2.0 beta with dependency compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' and i also have Fabric digits as followscompile('com.digits.sdk.android:digits:1.9.2@aar') { transitive = true; }
When i try to run digits code, it says RestAdapter could not be found. What change should i make please. From: guptavps@hotmail.com To: reply@reply.github.com; retrofit@noreply.github.com Subject: RE: [retrofit] Library Using Older Version of Retrofit (#1152) Date: Tue, 29 Dec 2015 06:56:42 +0000
Sorry for being novice, can you please tell me the steps to follow to avoid the conflict and error please...
Date: Mon, 28 Dec 2015 22:23:19 -0800 From: notifications@github.com To: retrofit@noreply.github.com CC: guptavps@hotmail.com Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps See #1209 and #1342. Retrofit2 now uses new package name retrofit2 and conflicts has been solved.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub https://github.com/square/retrofit/issues/1152#issuecomment-167735019.
Appreciate your reply Jake. I changed to SNAPSHOT version and i had make changes to many import statements in my app such as 1) Changed "import retrofit.Call" TO "import retrofit2.Call"2) Changed "import com.squareup.okhttp" to "import okhttp3" etc. Below is my change for GSON converter in my build gradle file. compile 'com.squareup.retrofit2:converter-gson:2.0.0-SNAPSHOT' compile 'com.squareup.retrofit2:retrofit:2.0.0-SNAPSHOT' Now i am able to run both Digits and my application but i am getting below exception now :(. Please guide me how to fix this please. Thanks java.lang.IllegalStateException: JSON must start with an array or an object.12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at com.google.gson.stream.JsonWriter.beforeValue(JsonWriter.java:626)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at com.google.gson.stream.JsonWriter.value(JsonWriter.java:418)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at com.google.gson.internal.bind.TypeAdapters$13.write(TypeAdapters.java:364)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at com.google.gson.internal.bind.TypeAdapters$13.write(TypeAdapters.java:348)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at retrofit2.GsonRequestBodyConverter.convert(GsonRequestBodyConverter.java:46)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at retrofit2.GsonRequestBodyConverter.convert(GsonRequestBodyConverter.java:29)12-29 13:17:32.308 25821-28649/starcare.mycare W/System.err: at retrofit2.RequestAction$Body.perform(RequestAction.java:245)12-29 13:17:32.309 25821-28649/starcare.mycare W/System.err: at retrofit2.RequestFactory.create(RequestFactory.java:63)12-29 13:17:32.309 25821-28649/starcare.mycare W/System.err: at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:124)12-29 13:17:32.309 25821-28649/starcare.mycare W/System.err: at retrofit2.OkHttpCall.execute(OkHttpCall.java:114)Date: Mon, 28 Dec 2015 23:02:57 -0800 From: notifications@github.com To: retrofit@noreply.github.com CC: guptavps@hotmail.com Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
You need to use the 2.0.0-SNAPSHOT until there is another release.
2.0.0-beta2 does not contain the package name change.
On Tue, Dec 29, 2015 at 1:59 AM guptavps notifications@github.com wrote:
I am trying to use Retrofit 2.0 beta with dependency compile
'com.squareup.retrofit:retrofit:2.0.0-beta2'
and i also have Fabric digits as
followscompile('com.digits.sdk.android:digits:1.9.2@aar') {
transitive = true;
}
When i try to run digits code, it says RestAdapter could not be found.
What change should i make please.
From: guptavps@hotmail.com
To: reply@reply.github.com; retrofit@noreply.github.com
Subject: RE: [retrofit] Library Using Older Version of Retrofit (#1152)
Date: Tue, 29 Dec 2015 06:56:42 +0000
Sorry for being novice, can you please tell me the steps to follow to
avoid the conflict and error please...
Date: Mon, 28 Dec 2015 22:23:19 -0800
From: notifications@github.com
To: retrofit@noreply.github.com
CC: guptavps@hotmail.com
Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps See #1209 and #1342. Retrofit2 now uses new package name
retrofit2 and conflicts has been solved.
—
Reply to this email directly or view it on GitHub.
—
Reply to this email directly or view it on GitHub
https://github.com/square/retrofit/issues/1152#issuecomment-167735019.
— Reply to this email directly or view it on GitHub.
Hi, Need your help on this. I am trying to upload file using Retrofit 2.0-SNAPSHOT and i am getting below error while uploading. Request you to point me to a fix please, bit urgent please.I am doing like this - @Multipart
@POST("document/uploadReport.json")
Call
You need to use the 2.0.0-SNAPSHOT until there is another release.
2.0.0-beta2 does not contain the package name change.
On Tue, Dec 29, 2015 at 1:59 AM guptavps notifications@github.com wrote:
I am trying to use Retrofit 2.0 beta with dependency compile
'com.squareup.retrofit:retrofit:2.0.0-beta2'
and i also have Fabric digits as
followscompile('com.digits.sdk.android:digits:1.9.2@aar') {
transitive = true;
}
When i try to run digits code, it says RestAdapter could not be found.
What change should i make please.
From: guptavps@hotmail.com
To: reply@reply.github.com; retrofit@noreply.github.com
Subject: RE: [retrofit] Library Using Older Version of Retrofit (#1152)
Date: Tue, 29 Dec 2015 06:56:42 +0000
Sorry for being novice, can you please tell me the steps to follow to
avoid the conflict and error please...
Date: Mon, 28 Dec 2015 22:23:19 -0800
From: notifications@github.com
To: retrofit@noreply.github.com
CC: guptavps@hotmail.com
Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
@guptavps See #1209 and #1342. Retrofit2 now uses new package name
retrofit2 and conflicts has been solved.
—
Reply to this email directly or view it on GitHub.
—
Reply to this email directly or view it on GitHub
https://github.com/square/retrofit/issues/1152#issuecomment-167735019.
— Reply to this email directly or view it on GitHub.
Likewise, even with this name change I am unable to get Twitter working alongside the remainder of my app (which is utilising the 3rd BETA).
I still get: java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/RestAdapter$Builder;
Can anyone share any insight?
I was able to resolve using the retrofit2.0-SNAPSHOT version. Let me know if you need exact dependency.
From: Thomas Clowes notifications@github.com Sent: Friday, January 8, 2016 11:17 AM To: square/retrofit Cc: guptavps Subject: Re: [retrofit] Library Using Older Version of Retrofit (#1152)
Likewise, even with this name change I am unable to get Twitter working alongside the remainder of my app (which is utilising the 3rd BETA).
I still get: java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/RestAdapter$Builder;
Can anyone share any insight?
Reply to this email directly or view it on GitHubhttps://github.com/square/retrofit/issues/1152#issuecomment-169968683.
Library Using Older Version of Retrofit · Issue #1152 ...https://github.com/square/retrofit/issues/1152#issuecomment-169968683 github.com Alright... 4 hours later, here's the fix. I've repackaged digits, twitter-core and retrofit 1.8 with jarjar to fix the package clash. You can find here a zip file ...
I have tried with the snapshot version and the 3rd BETA (this is the latest release so I assume that it includes the name change).
Running Fabric.with(this, new Twitter(authConfig));
gives the error "java.lang.VerifyError: com/twitter/sdk/android/core/internal/TwitterSessionVerifier"
Is there something that I am overlooking as regards getting these working side by side?
Changing to com.squareup.retrofit2:retrofit:2.0.0-beta3 fixes the issue.
I have the same issue with retrofit-2.0.0-beta3.jar
01-20 16:05:34.543: E/AndroidRuntime(22650): java.lang.NoClassDefFoundError: retrofit2.Retrofit$Builder
01-20 16:05:34.543: E/AndroidRuntime(22650): at co.gofun.retrofitdemo.MainActivity.get(MainActivity.java:27)
01-20 16:05:34.543: E/AndroidRuntime(22650): at co.gofun.retrofitdemo.MainActivity.onCreate(MainActivity.java:21)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.Activity.performCreate(Activity.java:5451)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2346)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2443)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.ActivityThread.access$800(ActivityThread.java:157)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.os.Handler.dispatchMessage(Handler.java:110)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.os.Looper.loop(Looper.java:193)
01-20 16:05:34.543: E/AndroidRuntime(22650): at android.app.ActivityThread.main(ActivityThread.java:5348)
01-20 16:05:34.543: E/AndroidRuntime(22650): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 16:05:34.543: E/AndroidRuntime(22650): at java.lang.reflect.Method.invoke(Method.java:515)
01-20 16:05:34.543: E/AndroidRuntime(22650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
01-20 16:05:34.543: E/AndroidRuntime(22650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
01-20 16:05:34.543: E/AndroidRuntime(22650): at dalvik.system.NativeStart.main(Native Method)
@StayZeal If you are using Android Studio, try to "Invalidate Caches".
Still not able to integrate Twitter within my latest app because of the java.lang.NoClassDefFoundError: retrofit2.Retrofit$Builder issue..
Invalidating caches has not worked for me.
Can anyone give any detailed insight into how they got the Twitter SDK working alongside Beta 3?
Didn't work for me as well.
Any working solution yet?
Same error for me, whats up with it ?
Same issue / error here with latest version of Fabric / Twitter.
Reached out to support 2 weeks ago, still no answer.
Did anyone find a workaround for this?
Any update on this? Can we use Digits with latest Retrofit now?
Update pls! What's the workaround ?
I recently was testing out Twitter Digits and Retrofit.
However when I build the app I get this error. It cannot find the build adapter, which is no longer in Retrofit 2.0.
Do I have to wait till Digits Updates its module to Retrofit 2 or is there any other options to use them both together. Forcing one module, here Digits, to use Retrofit 1.9 and my app to use 2.0.