error when getting data from a web service with Retrofit

0

I have a finished app that sometimes crashes my users (he does not do it to me) ... google sends me this stack trace:

java.lang.NullPointerException: 
at com.mal.saul.preciosbitcoinmexico.Fragment.FragmentPrincipal. 
   realizarCambioPrecio(FragmentPrincipal.java:181)  
at com.mal.saul.preciosbitcoinmexico.Fragment.FragmentPrincipal.
   access$200(FragmentPrincipal.java:42)
at com.mal.saul.preciosbitcoinmexico.Fragment.FragmentPrincipal$2.
   onResponse(FragmentPrincipal.java:160)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.
   run(ExecutorCallAdapterFactory.java:68)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller. 
   run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)   

To what I understand I am having the error in the onResponse method of Retroft, here I am attaching them together with the onFailure:

@Override
        public void onResponse(Call<ValoresBtcPrecioResponse> call, 
        Response<ValoresBtcPrecioResponse> response) {                
            ValoresBtcPrecioResponse valoresBtcPrecioResponse = 
            response.body();
            if(valoresBtcPrecioResponse != null){
                valoresBtcPrecios = 
                valoresBtcPrecioResponse.getValoresBtcPrecio();
                mostrarValoresBtcPrecio();  //muestra a traves de Textviews 
                //los valores contenids en valoresBtcPrecios (es global)                                                        
            }
            else {
                Toast.makeText(getActivity(), "Bitso No Está Disponible Por 
            el Momento", Toast.LENGTH_SHORT).show();
            }
        }
@Override
        public void onFailure(Call<ValoresBtcPrecioResponse> call, Throwable          
        t) {                     
            Toast.makeText(getActivity(), "Sin Conexión a Internet", 
            Toast.LENGTH_SHORT).show();
        }                                                  

As I mentioned before, the error did not come to my attention, it is the reports sent by the users, I had put the if (valuesBtcPriceResponse! = null) precisely to avoid the null pointer, any idea of how to solve it?

    
asked by Saul_programa 02.06.2017 в 00:37
source

0 answers