question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashing when trying to open request details

See original GitHub issue

Describe the bug I’m able to see the list of made requests, when I try to open the request details to see respons / headers etc… Chucker will creash.

Crash Log

2019-09-29 13:20:14.457 30344-30344/com.myspringring E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.myspringring, PID: 30344
    java.lang.RuntimeException: Unable to resume activity {com.myspringring/com.chuckerteam.chucker.api.internal.ui.transaction.TransactionActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3429)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference
        at androidx.core.app.ComponentActivity.dispatchKeyShortcutEvent(ComponentActivity.java:85)
        at androidx.lifecycle.LiveData.observe(LiveData.java:172)
        at com.chuckerteam.chucker.api.internal.ui.transaction.TransactionActivity.onResume(TransactionActivity.java:89)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
        at android.app.Activity.performResume(Activity.java:6783)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6119) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

The following code is where I initialize Chucker

public static Retrofit getRetrofit(final Context context) {

        String baseURL = getAPIBaseUrl();
        Retrofit.Builder retrofitBuilder;
        OkHttpClient.Builder builder = null;

        // Define the interceptor, add authentication headers
        Interceptor interceptor = new Interceptor() {
            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {

                // TODO improve this
                if (!GlobalUtils.checkForInternetConnection(context, TAG)) {
                        //logThis(TAG, "No Internet Connection", null);
                    throw new NoConnectivityException(context);
                }

                Request newRequest = chain.request().newBuilder()
                        /**
                        Headers
                        **/
                return chain.proceed(newRequest);
            }
        };

        // Add the interceptor to OkHttpClient
        builder = new OkHttpClient.Builder();
        builder.connectTimeout((int) Global.getFirebaseRemoteConfigValue(context, Integer.class, Firebase.API_TIMEOUT_SHORT.toString(), 0), TimeUnit.SECONDS); // connect timeout
        builder.readTimeout((int) Global.getFirebaseRemoteConfigValue(context, Integer.class, Firebase.API_TIMEOUT_LONG.toString(), 0), TimeUnit.SECONDS); // write timeout
        builder.writeTimeout((int) Global.getFirebaseRemoteConfigValue(context, Integer.class, Firebase.API_TIMEOUT_LONG.toString(), 0), TimeUnit.SECONDS); // read timeout
        builder.interceptors().add(interceptor);

        // Add chuck interceptor
        builder.addInterceptor(new ChuckerInterceptor(context));

        if (isDebug()) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            builder.addInterceptor(logging);
        }

        // Set the custom client when building adapter
        retrofitBuilder = new Retrofit.Builder()
                .baseUrl(baseURL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .client(builder.build());

        return retrofitBuilder.build();
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cortinicocommented, Oct 3, 2019

I’m using Chucker 3.0.1, yes it happening on every device I tested on.

Given this, I have the feeling this might be related to the interaction between Chucker and your project.

but I can share related code snippets / screenshots / videos.

Looking forward to it.

I’m using AndroidX if that might help.

Can I ask you to try the latest snapshot and let me know if that crashes as well? https://github.com/ChuckerTeam/chucker#snapshots-

0reactions
cortinicocommented, Oct 7, 2019

Awesome, then I’m going to close here

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Crashing Apps on an iPhone or Android?
10 Solutions to fix App Crashes and Keep Apps Running: For Apple iPhone, Samsung Galaxy, LG, Lenovo and Sony Xperia smartphones. If you've...
Read more >
App crashing immediately on start up after upgrading to iOS12.
Running fine in simulator but crashes in device. No crash logs recorded. In line error shown after launching the app Thread 1: EXC_BAD_ACCESS...
Read more >
What to do when your apps keep crashing - Popular Science
Press and hold the app's icon on the home screen, then tap Remove App from the menu that appears, followed by Delete App....
Read more >
Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >
My app crashes when I try to send a request to the server
This is the event handling thread of the app and handles all events (User initiated or system initiated). If the thread is blocked, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found