apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Crash in ApptentiveViewActivity.onSaveInstanceState #189

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi, I do get the following crash report

I assume this can happen when something else crashes in onCreate before addFragmentToAdapter() is called. The generic catch should be removed there to find the real issue. A null check in onSaveInstance state could be a quick fix.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.apptentive.android.sdk.adapter.ApptentiveViewPagerAdapter.getFragmentTag(int)' on a null object reference at com.apptentive.android.sdk.ApptentiveViewActivity.onSaveInstanceState(ApptentiveViewActivity.java:300) at android.app.Activity.performSaveInstanceState(Activity.java:1557) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1465) at android.app.ActivityThread.callActivityOnSaveInstanceState(ActivityThread.java:5046) at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4359) at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4341) at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4416) at android.app.servertransaction.StopActivityItem.execute(StopActivityItem.java:41) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1977) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6936) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

Edit: version is 5.3.1

weeeBox commented 4 years ago

Hey @TheDoorNextBoy,

Sorry for the issue: we'll take a look at it asap.

CaseyApptentive commented 4 years ago

@TheDoorNextBoy thanks for the report! We're digging in.

In the meantime, could you email us at support@apptentive.com with which the account you're working on? I'd like to keep your Customer Success Manager in the loop so they can help coordinate, if need be.

Thanks again.

twinklesharma1311 commented 4 years ago

Hey @TheDoorNextBoy , can you please let me know the steps that lead to this crash? I am trying to reproduce the same scenario in order to debug the real issue.

weeeBox commented 4 years ago

@TheDoorNextBoy, did you get the crash log from the crash reporting tool or were you able to reproduce it locally? Do you have any other logs on top of the crash log?

ghost commented 4 years ago

Hi there, thanks for your fast response! @twinklesharma1311 , @weeeBox I can't reproduce it locally, but it's our number 1 crash on Firebase Crashlytics. I will send you the account details to your support address. Maybe you can see more in your own logs.

ghost commented 4 years ago

I sent a message to support@apptentive.com earlier and got the following back

We recently received a message from you but were unable to find the associated record. Your message was not added to Apptentive.

Could you check that or give me another email address? Thx

CaseyApptentive commented 4 years ago

@TheDoorNextBoy very sorry about the issue using support@apptentive.com -- I'm looking into it.

Can you email me directly at casey@apptentive.com?

ghost commented 4 years ago

I am also facing the same crash. Using the SDK version 5.4.1 Before the crash my screen freezes with a black screen and logs show the following error:

E/Apptentive: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class at android.view.LayoutInflater.inflate(LayoutInflater.java:551) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.apptentive.android.sdk.ApptentiveViewActivity.onCreate(ApptentiveViewActivity.java:143) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) at android.app.ActivityThread.access$1100(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:657) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.inflate(LayoutInflater.java:527) at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.apptentive.android.sdk.ApptentiveViewActivity.onCreate(ApptentiveViewActivity.java:143)  at android.app.Activity.performCreate(Activity.java:6876)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)  at android.app.ActivityThread.access$1100(ActivityThread.java:222)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:158)  at android.app.ActivityThread.main(ActivityThread.java:7229)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:631) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)  at android.view.LayoutInflater.inflate(LayoutInflater.java:527)  at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.apptentive.android.sdk.ApptentiveViewActivity.onCreate(ApptentiveViewActivity.java:143)  at android.app.Activity.performCreate(Activity.java:6876)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)  at android.app.ActivityThread.access$1100(ActivityThread.java:222)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:158)  at android.app.ActivityThread.main(ActivityThread.java:7229)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f010148 a=3} at android.content.res.TypedArray.getDrawable(TypedArray.java:883) at android.view.View.(View.java:4225) at android.view.ViewGroup.(ViewGroup.java:589) at android.view.ViewGroup.(ViewGroup.java:585) at android.support.v7.widget.Toolbar.(Toolbar.java:233) at android.support.v7.widget.Toolbar.(Toolbar.java:229) at java.lang.reflect.Constructor.newInstance(Native Method)  at android.view.LayoutInflater.createView(LayoutInflater.java:631)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)  at android.view.LayoutInflater.inflate(LayoutInflater.java:527)  at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.apptentive.android.sdk.ApptentiveViewActivity.onCreate(ApptentiveViewActivity.java:143)  at android.app.Activity.performCreate(Activity.java:6876)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)  at android.app.ActivityThread.access$1100(ActivityThread.java:222)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:158)  at android.app.ActivityThread.main(ActivityThread.java:7229)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

And then after home option pressed App crashes with following logs:

E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.apptentive.android.sdk.adapter.ApptentiveViewPagerAdapter.getFragmentTag(int)' on a null object reference at com.apptentive.android.sdk.ApptentiveViewActivity.onSaveInstanceState(ApptentiveViewActivity.java:302) at android.app.Activity.performSaveInstanceState(Activity.java:1474) at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1317) at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:5398) at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4700) at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4774) at android.app.ActivityThread.access$1400(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1824) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

weeeBox commented 4 years ago

Hey @prashantbankar,

Could you share the contents of your build.gradle file and your app theme?

CaseyApptentive commented 4 years ago

@TheDoorNextBoy could you share the contents of your build.gradle file and your app theme as well?

Thanks!

ghost commented 4 years ago

@weeeBox

app theme Theme.AppCompat.Light.NoActionBar

build.gradle buildToolsVersion '28.0.0' compileSdkVersion 28 targetSdkVersion 28 implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.android.support:support-compat:28.0.0'

weeeBox commented 4 years ago

Thanks @prashantbankar,

Do you also have any reproduction steps?

ghost commented 4 years ago

@weeeBox I am firing up the event

Apptentive.engage(baseContext, event);

then calling startActivity()

I tried the troubleshoot but it didn't help

EDIT: the following log was printed though: I/Apptentive: Launching interaction: EnjoymentDialog

ghost commented 4 years ago

@weeeBox Any update on this?

weeeBox commented 4 years ago

@prashantbankar, we're trying to reproduce the issue on our end. We have a fix ready but really want to figure out the underlying cause of the inflating exception.

weeeBox commented 4 years ago

@prashantbankar, what Gradle plugin version do you use?

ghost commented 4 years ago

@weeeBox Gradle Plugin version 3.0.1 and Gradle version 4.1

CaseyApptentive commented 4 years ago

Thanks, @prashantbankar ! We're digging into this.

CaseyApptentive commented 4 years ago

@TheDoorNextBoy and @prashantbankar. We've released SDK version 5.4.7 with a fix for this crash. Can you update and let me know if you're still having any issues?

Thanks!

ghost commented 4 years ago

@CaseyApptentive Thanks for your fast response, But I am really disappointed about your "fix".

        } catch (Exception e) {
-           ApptentiveLog.e(e, "Exception in %s.onCreate()", ApptentiveViewActivity.class.getSimpleName());
+           ApptentiveLog.e(e, "Exception in %s.onCreate(). Finishing activity...", ApptentiveViewActivity.class.getSimpleName());
            logException(e);
+           finish();
        }

Just catching everything and finishing can not be a solution. I'd rather have the App crash and know about it than having unexpected behaviour and bad reviews. I understand that there is maybe not enough information at the moment to properly fix it. But if you would not use those generic catches I could have sent you better logs in the first place.

Please let me know if you plan another update. Thanks

weeeBox commented 4 years ago

@TheDoorNextBoy, we understand your frustration but cannot reproduce the bug on any configuration (Gradle Plugin/Wrapper version, legacy Android Studio, different app themes). We released a fix to prevent devices from crashing and continued investigating. There will be no unexpected behaviour: if the problem persists - the users won't be able to see Love Dialog. It would be really helpful if you can provide the content of your app and project level build.gradle files (we need to know your dependencies and Gradle Plugin/Wrapper versions) and your styling files (what theme you use and how you configure it). Hope, this makes it more clear and sorry for the inconvenience.

ghost commented 4 years ago

Hi @weeeBox, Sorry for my late reply. I was a bit busy the last days. We will release a new version with 5.4.7 in a few days as soon as QA approves.

Actually our theme could really be an issue. Our parent theme is Theme.MaterialComponents.Light.NoActionBar.Bridge from implementation 'com.google.android.material:material:1.0.0' Maybe you could check it. If I find some time today I'll try another one.

We are using the following androidx libraries:

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

Our gradle version is gradle-5.4.1

weeeBox commented 4 years ago

Hi @TheDoorNextBoy, we need to create an app with the very same dependencies, Gradle plugin/wrapper versions and styling as your app in order for being able to reproduce the issue. Would you be able to provide these?