My application crashes when I try to debug it, but it works fine in startup mode. I looked at the stack trace and I know that this is due to the callback code.
Any ideas why the app crashes only in debug mode?
Here is a snippet:
public class MoviePosterFragment extends Fragment { private void updateMoviePosters(final RecyclerView rv) { MovieAPI mMovieAPI = NetworkAPI.createService(MovieAPI.class); Callback<movieGeneral> callback = new Callback<movieGeneral>() { @Override public void success(movieGeneral mMovieGeneral, Response response) { updateMovieGrid(rv, mMovieGeneral); Toast.makeText(getActivity(), "callback success!", Toast.LENGTH_LONG).show(); } @Override public void failure(RetrofitError error) { int a =0;
Network API:
public class NetworkAPI { //Volatile keyword ensures that multiple threads handle the unique/instance correctly private volatile static NetworkAPI uniqueInstance; public static final String POP_MOVIES_URL = "http://api.themoviedb.org/3/discover/movie?"; private final String API_KEY = "xxxxxxxxxxxxxxxxxxxxxx"; final String SORT_PARAM = "sort_by"; final String PAGE = "page"; final String KEY = "api_key"; private static RestAdapter.Builder builder = new RestAdapter.Builder() .setEndpoint(POP_MOVIES_URL) //API endpoint .setClient(new OkClient(new OkHttpClient())); //setClient: the HTTP client used for requests public static <S> S createService(Class<S> serviceClass) { RestAdapter adapter = builder.build(); return adapter.create(serviceClass); } }
Interface:
public interface MovieAPI { @GET("/3/discover/movie") void fetchPopMovies ( //@Query: specifies the query key name with the value of the annotated parameter. @Query("sort_by") String SORT_PARAM, @Query("api_key") String API_KEY, retrofit.Callback<movieGeneral> cb
Stacktrace:
02-26 00:34:32.544 1109-1109/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL 02-26 00:34:44.145 1109-1116/example.user.popmovie E/art: art::mirror::Object* art::StackVisitor::GetThisObject() const unimplemented Failed to determine this object of abstract or proxy method: void example.user.popmovie.utils.MovieAPI.fetchPopMovies(java.lang.String, java.lang.String, retrofit.Callback) 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetStringUTFChars called with pending exception 'android.view.InflateException' thrown in android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean):548 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] in call to GetStringUTFChars 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] from int android.util.Log.println_native(int, int, java.lang.String, java.lang.String) 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x8759bef0 self=0xb4f07800 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] | sysTid=1109 nice=0 cgrp=apps sched=0/0 handle=0xb6f67ec8 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] | state=R schedstat=( 0 0 0 ) utm=30 stm=10 core=2 HZ=100 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] | stack=0xbe4f4000-0xbe4f6000 stackSize=8MB 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held) 02-26 00:34:44.315 1109-1109/example.user.popmovie A/art: sart/runtime/check_jni.cc:65] native:
source share