retrofit2

RxAndroid Release Apk is not working for build 25.0.2

五迷三道 提交于 2019-12-05 19:10:11
I have posted this on rxandroid issue page too but no response its been 4 days but no response , problem is in debug apk rxjava functionalities are working as expected , but in release apk , only functionalities related to rxjava or rxandroid are not working at all build.gradle(project) apply plugin: 'com.android.application' //or apply plugin: 'java' apply plugin: 'me.tatarka.retrolambda' apply plugin: 'com.jakewharton.hugo' apply plugin: 'android-apt' def AAVersion = '4.1.0' android { compileSdkVersion 25 buildToolsVersion '25.0.2' defaultConfig { applicationId "com.jutt.example1"

Error uploading a file using Retrofit 2

匆匆过客 提交于 2019-12-05 18:40:11
问题 I'm trying to upload a file (picture) to the server using Retrofit 2 . I'm following that tutorial which seems pretty easy at first, but didn't work in my case... When I call the API function, i'm always getting this error: W/System.err: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 W/System.err: at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:190) W/System.err: at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166) W/System.err: at retrofit2.Retrofit$1.invoke

Retrofit 2 - How to show progress bar On Receiving JSON Response

断了今生、忘了曾经 提交于 2019-12-05 18:14:52
I am using multiple Fragments in tabbed activity to show json data. I want to show progress bar whenever the response is received in every fragment. private void loadJSON() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASEURL) .addConverterFactory(GsonConverterFactory.create()) .build(); newsAPI = retrofit.create(NewsAPI.class); Call < JSONResponse > call = newsAPI.topNews("soure", "api-key"); call.enqueue(new Callback < JSONResponse > () { @Override public void onResponse(Call < JSONResponse > call, Response < JSONResponse > response) { Log.v("this", "Yes!"); } } @Override public

RXJava2: correct pattern to chain retrofit requests

折月煮酒 提交于 2019-12-05 18:02:07
问题 I am relatively new to RXJava in general (really only started using it with RXJava2), and most documentation I can find tends to be RXJava1; I can usually translate between both now, but the entire Reactive stuff is so big, that it's an overwhelming API with good documentation (when you can find it). I'm trying to streamline my code, an I want to do it with baby steps. The first problem I want to solve is this common pattern I do a lot in my current project: You have a Request that, if

RxJava,Retrofit Error :Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

隐身守侯 提交于 2019-12-05 16:51:39
I am using Retrofit and RxJava Library and trying to parse this url: My code is as below. APIInterface.java public interface APIService { @GET("/bins/tdze5") Observable<List<Student>> getdata(); } MainActivity.java public class MainActivity extends AppCompatActivity { private RecyclerView recyclerView; private List<Student> list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); recyclerView = (RecyclerView) findViewById(R.id.recyclerview); getData(); } private void getData() { Retrofit retrofit = new

Retrofit2:Expected BEGIN_ARRAY but was STRING at line 1 column 268 path $[0].images

*爱你&永不变心* 提交于 2019-12-05 16:22:11
I know this is not the first time someone asking about this problem but with Retrofit2 I can't find the right solution to my problem. I have an object that contains a list of String. when I want to convert JSON response to my object all other fields are ok but I got this error for converting the list of string to my list: Retrofit2: Expected BEGIN_ARRAY but was STRING at line 1 column 268 path $[0].images This is my API: @POST("/cp/api/")// get list of products Call<List<Product>> Get_Special_Products(@Body Object request); My Retrofit setting: public Retrofit Store_retrofit(OkHttpClient

Simple login form with Retrofit

那年仲夏 提交于 2019-12-05 13:44:54
I'm starting to work with Retrofit but I'm stuck on this simple step. I have a login form and I'm trying to authenticate with the server but I just can't send the request. This is what I've tried: My Retrofit client: private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); private static Retrofit.Builder builder = new Retrofit.Builder() .baseUrl(API_BASE_URL) .addConverterFactory(GsonConverterFactory.create()); public static <S> S createService(Class<S> serviceClass) { Retrofit retrofit = builder.client(httpClient.build()).build(); return retrofit.create(serviceClass); } My

HTTP FAILED: java.net.SocketException: Socket closed; doesn't fire up exception handling methods

て烟熏妆下的殇ゞ 提交于 2019-12-05 10:51:53
I have an RxJava chain request that should release some locks onError(), or onComplete(), so, basically, what my problem is: when I set read, connect and write timeouts to my OkHttpClient, I don't get the desired behavior. I'm using Retrofit2 and OkHttp3.6.0 Here's my simplified client: OkHttpClient.Builder builder = new OkHttpClient.Builder() .readTimeout(30, TimeUnit.SECONDS) .connectTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) OkHttpClient okHttpClient = builder.build(); Here's a simplified version of the chain request I have: public <T extends Response> Observable<T>

Retrofit for android @Multipart remove default headers

倾然丶 夕夏残阳落幕 提交于 2019-12-05 10:50:46
Making a @Multipart request adds these default headers (Content-Transfer-Encoding, Content-Type) for each part, is there any way to remove them? //REQUEST BODY --25d35373-d2c3-46a3-969f-f5a1fd5f781a Content-Disposition: form-data; name="client_id" Content-Transfer-Encoding: binary <-- remove this one Content-Type: application/json; charset=UTF-8 <-- remove this one Content-Length: 34 "40ccfee680a844780a41fbe23ea89934" // NOTE: I do not have access to the server so there is no way I will be able to make the server accept these headers. You can build multipart body by your self in this way

Get JSON object one by one from JSON array in Android using Retrofit and RxJava

安稳与你 提交于 2019-12-05 09:47:58
I am using retrofit to hit my network api which returns json array. I am doing so using following code- Observable<MyJson[]> response = (Observable<MyJson[]>)mNetworkService.getReadyObserverable(mNetworkService.getNetworkServiceApi().getMyDataJsons(), MyJson.class, true, useCache); mAirlineSubscription = response.subscribe(new Observer<MyJson[]>() { @Override public void onCompleted() { Log.d(TAG, "getData completed.."); } @Override public void onError(Throwable e) { Log.e(TAG, "onError: " + e.getLocalizedMessage()); } @Override public void onNext(MyJson[] myJsonData) { //I want here json data