Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashing when trying to open request details #124

Closed
KhalilTB opened this issue Sep 29, 2019 · 5 comments
Closed

App crashing when trying to open request details #124

KhalilTB opened this issue Sep 29, 2019 · 5 comments
Milestone

Comments

@KhalilTB
Copy link

KhalilTB commented Sep 29, 2019

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();
    }
@cortinico
Copy link
Member

Thanks for the report @KhalilTB

  • Which version of Chucker are you using?
  • Is this happening on every device?
  • Is this happening on emulators?
  • Would you be able to provide a project where I can reproduce this crash?

@KhalilTB
Copy link
Author

KhalilTB commented Oct 1, 2019

Thanks for the report @KhalilTB

  • Which version of Chucker are you using?
  • Is this happening on every device?
  • Is this happening on emulators?
  • Would you be able to provide a project where I can reproduce this crash?

I'm using Chucker 3.0.1, yes it happening on every device I tested on. (Nexus 6 running Android 7.1.1, Huawei P20 Pro running Android 9.0, and on the emulator as well running Android 9.0).
Unfortunately I cannot share the entire project since it's not owned by me, but I can share related code snippets / screenshots / videos. I'm using AndroidX if that might help.

@cortinico
Copy link
Member

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-

@KhalilTB
Copy link
Author

KhalilTB commented Oct 7, 2019

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

This resolved the issue, now it's working perfectly. Thank you.

@cortinico cortinico added this to the 3.1.0 milestone Oct 7, 2019
@cortinico
Copy link
Member

Awesome, then I'm going to close here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants