Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit 2 on Android 6 sets zero path parameters

I am using Retrofit 2 library version 2.3.0 and all of a sudden it started replacing integer path parameters with zero instead of the actual number.

I am using Kotlin (1.2.21) and I have a method like:

@GET("posts/{postId}")
fun getPosts(@Path("postId") postId: Long): Single<Post>

This worked as should but now when I run my app on Android 6 (both a devices and an emulator) the postId path parameter is always a zero i.e. posts/0 is called. Android 7 and 8 are fine. There was no change to the Retrofit and OkHttp versions, also the interface has not changed.

I have looked into the built request and the OkHttpCall inside has args array with one value of type Long with value 0. This is only on Android 6, others have the correct value there. The ServiceMethod has the correct URL set in the interface and it has one ParameterHandler for the postId of type BuiltInConverter.ToStringConverter.

App is multiDexed and ProGuard is not used. What could be happening?

like image 768
shelll Avatar asked Feb 07 '18 13:02

shelll


1 Answers

It was caused by the Instant Run. Retrofit works perfectly after I disabled it.

like image 55
shelll Avatar answered Oct 15 '22 15:10

shelll