Kazunari
Kazunari

Reputation: 278

Retrofit is not stopping on breakpoint

I'm facing that problem, when I make a call of retrofit, that call doesn't stop on breakpoint.

ClashResponse clashResponse = new ClashResponse();

    clashApi = clashResponse.getClashApi();

    clashApi.getAllArenas().enqueue(new Callback<String>() {
        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            ClashApiBuilder<ArenaData> clashApiBuilder = new ClashApiBuilder(ArenaData.class);

            arenaList = clashApiBuilder.convert(String.valueOf(call));
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            t.getCause();
        }
    });

My gradle

  //Retrofit
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'

My builder of retrofit:

public ClashResponse(){
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(SERVER_URL)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    return retrofit.create(ClashApi.class);
}

Upvotes: 1

Views: 903

Answers (1)

Vivek Pratap Singh
Vivek Pratap Singh

Reputation: 82

If you want to debug your Api call use chuck interceptor it will work in debug mode only. Add following dependencies in your apps build.gradle.

 debugCompile 'com.readystatesoftware.chuck:library:1.1.0'
 releaseCompile 'com.readystatesoftware.chuck:library-no-op:1.1.0'

get reference of okHttp3

 public OkHttpClient getClient(Context context) {
    // Add the interceptor to OkHttpClient
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.addInterceptor(new ChuckInterceptor(context));
    builder.readTimeout(READ_TIMEOUT, TimeUnit.MINUTES);
    builder.connectTimeout(CONNECT_TIMEOUT, TimeUnit.MINUTES);
    return builder.build();
}

now get Instance of Retrofit and add this okHttp Client

 public RestApi connectToApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_DOC_URL)
                //Data converter
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .client(getClient(context))
                .build();
        return retrofit.create(RestApi.class);
}

Now all the Api calls you can track from notification bar.

Upvotes: 1

Related Questions