apptentive / apptentive-android

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

'FragmentManagerImpl.isDestroyed()' on a null object reference #182

Closed astefanyuk closed 4 years ago

astefanyuk commented 4 years ago

Apptentive version 5.4.3. Android 9.0 Crash on dismiss Apptentive popup message.

java.lang.RuntimeException: Unable to destroy activity {com.apptentive.android.sdk.ApptentiveViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4480) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4498) at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39) 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:1818) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6762) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at androidx.fragment.app.Fragment.performDetach(Fragment.java:2854) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1036) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1240) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1305) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2658) at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2643) at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329) at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366) at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233) at com.apptentive.android.sdk.ApptentiveBaseActivity.onDestroy(ApptentiveBaseActivity.java:35) at android.app.Activity.performDestroy(Activity.java:7395) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1307)

weeeBox commented 4 years ago

Hey @astefanyuk,

Sorry for the issue. We'll take a look asap.

astefanyuk commented 4 years ago

Hi. Thanks for quick response. Let me know if you need any details

On Wed, Jul 17, 2019, 9:36 AM Alex Lementuev notifications@github.com wrote:

Hey @astefanyuk https://github.com/astefanyuk,

Sorry for the issue. We'll take a look asap.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apptentive/apptentive-android/issues/182?email_source=notifications&email_token=AADMKTTFHXUPVXT2DOH6F5TP724XRA5CNFSM4IEDFMI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2DGFTA#issuecomment-512123596, or mute the thread https://github.com/notifications/unsubscribe-auth/AADMKTUWWJ3QUPTQ2EZAR6LP724XRANCNFSM4IEDFMIQ .

weeeBox commented 4 years ago

Hey @astefanyuk,

We have some difficulties reproducing the problem. Would you be able to provide the content of your build.gradle files?

astefanyuk commented 4 years ago

Here is some information.

ext.buildConfig = [ 'compileSdk': 29, 'targetSdk' : 29, 'minSdk' : 19, 'gradle' : '3.4.2', 'kotlin' : '1.3.41' ]

androidx.dynamicanimation:dynamicanimation:1.1.0-alpha02 androidx.annotation:annotation:1.1.0 androidx.appcompat:appcompat:1.1.0-rc01 androidx.cardview:cardview:1.0.0 androidx.constraintlayout:constraintlayout:1.1.3 com.google.android.material:material:1.1.0-alpha08, androidx.multidex:multidex:2.0.1", androidx.multidex:multidex-instrumentation:2.0.0, androidx.legacy:legacy-preference-v14:1.0.0 androidx.recyclerview:recyclerview:1.1.0-beta01, androidx.legacy:legacy-support-v13:1.0.0

Our Fragments extended from androidx.fragment.app.Fragment Activity from androidx.appcompat.app.AppCompatActivity Theme based on Theme.AppCompat.Light.NoActionBar

weeeBox commented 4 years ago

Thanks for the info

weeeBox commented 4 years ago

@astefanyuk, seems like we're running into this issue. We'll keep investigating and get back to you when we have a solution.

faizfolio commented 4 years ago

App crashes on closing message center screen on Samsung Galaxy devices(S8, S8+, S9), working fine on the rest of the devices. Android version 8.0

Project config: compileSdkVersion = 28 minSdkVersion 21

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.squaretrade.android.ppa, PID: 8698 java.lang.RuntimeException: Unable to destroy activity {com.squaretrade.android.ppa/com.apptentive.android.sdk.ApptentiveViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4603) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4621) at android.app.ActivityThread.-wrap5(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isDestroyed()' on a null object reference at androidx.fragment.app.Fragment.performDetach(Fragment.java:2844) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1034) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2656) at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2641) at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329) at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366) at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233) at com.apptentive.android.sdk.ApptentiveBaseActivity.onDestroy(ApptentiveBaseActivity.java:35) at android.app.Activity.performDestroy(Activity.java:7462) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1255) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4590) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4621)  at android.app.ActivityThread.-wrap5(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6938)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

CaseyApptentive commented 4 years ago

Hi @faizfolio, thanks for the report and apologies for the inconvenience. Happy to look into this with you. I'd love to get an email thread going to help more deeply. Could you email me at casey@apptentive.com and I'll help coordinate?

I'll look into the crash in the meantime. Would love additional details like:

Thanks!

weeeBox commented 4 years ago

@faizfolio, would you able to provide the content of your build.gradle file (the dependencies section)

harisf3 commented 4 years ago

also happening on Nexus emulator, tested on Android O and Android P.

faizfolio commented 4 years ago

@weeeBox Here are the dependencies of my project `

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'fr.bmartel:jspeedtest:1.32.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha08'
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "androidx.annotation:annotation:1.0.2"
implementation "com.google.android.gms:play-services-vision:18.0.0"
implementation "com.google.android.gms:play-services-identity:17.0.0"
implementation 'com.google.zxing:core:3.2.1'
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-dynamic-links:18.0.0"
implementation "com.google.firebase:firebase-config:18.0.0"
implementation ("com.squareup.retrofit2:retrofit:2.5.0") {
    // exclude Retrofit’s OkHttp peer-dependency module and define your own module import
    exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
implementation "com.squareup.okhttp3:okhttp:3.12.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.12.0"
implementation("com.segment.analytics.android:analytics:4.3.1")
implementation('com.crashlytics.sdk.android:crashlytics:2.9.7@aar') {
    transitive = true
}
implementation ("io.branch.sdk.android:library:3.0.1"){
    exclude module: 'answers-shim'
}
implementation "com.amazonaws:aws-android-sdk-s3:2.6.7"
implementation "com.apptentive:apptentive-android:5.4.3"
implementation 'com.fnp:material-preferences:0.1.4'
implementation 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
implementation 'com.jakewharton:disklrucache:2.0.2'    
implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
implementation 'commons-io:commons-io:2.6'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'com.wajahatkarim3.EasyFlipView:EasyFlipView:2.0.5'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation "androidx.room:room-runtime:2.1.0"
annotationProcessor "androidx.room:room-compiler:2.1.0"
implementation 'com.romandanylyk:pageindicatorview:1.0.3'
implementation "com.salesforce.service:chat-core:3.5.0"
implementation 'com.makeramen:roundedimageview:2.3.0'
testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-core:2.8.9"
testImplementation "org.powermock:powermock-module-junit4:1.7.3"
testImplementation "org.powermock:powermock-api-mockito2:1.7.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.1.1"
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation "androidx.test:runner:1.1.1"
androidTestImplementation "androidx.test:rules:1.1.1"
qaImplementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.felipecsl.asymmetricgridview:library:2.0.1'

`

weeeBox commented 4 years ago

Hey @faizfolio, thanks for the info!

faizfolio commented 4 years ago

@weeeBox Any update on this issue? We are getting this issue in our production build and we will appreciate if you guys can fix it as soon as possible.

CaseyApptentive commented 4 years ago

Hi @faizfolio, we're still looking at this. Can you email me at casey@apptentive.com and I'll follow up with more details?

Thanks!

astefanyuk commented 4 years ago

Failed with versions: def androidDesignVersion = '1.1.0-alpha09' def androidTestRulesVersion = '1.3.0-alpha02' def androidTestRunnerVersion = '1.1.1' def androidTestMonitorVersion = '1.3.0-alpha02' def androidFragmentTestVersion = '1.2.0-alpha01' def androidXAppCompatVersion = '1.1.0-rc01' def androidXRecyclerViewVersion = '1.1.0-beta01' def androidXAnnotationVersion = '1.1.0' def androidXAnimationVersion = '1.1.0-alpha02'

Works fine with def androidDesignVersion = '1.1.0-alpha01' def androidTestRulesVersion = '1.1.2-alpha01' def androidTestRunnerVersion = '1.1.2-alpha01' def androidTestMonitorVersion = '1.1.2-alpha01' def androidFragmentTestVersion = '1.1.0-alpha04' def androidXAppCompatVersion = '1.1.0-alpha02' def androidXRecyclerViewVersion = '1.1.0-alpha02' def androidXAnnotationVersion = '1.1.0' def androidXAnimationVersion = '1.0.0'

            'support'     : [
                    'animation'              : "androidx.dynamicanimation:dynamicanimation:$androidXAnimationVersion",
                    'annotations'            : "androidx.annotation:annotation:$androidXAnnotationVersion",
                    'appcompat'              : "androidx.appcompat:appcompat:$androidXAppCompatVersion",
                    'cardview'               : "androidx.cardview:cardview:$androidXCardViewVersion",
                    'constraint'             : "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion",
                    'design'                 : "com.google.android.material:material:$androidDesignVersion",
                    'multidex'               : "androidx.multidex:multidex:$multidexVersion",
                    'multidexInstrumentation': "androidx.multidex:multidex-instrumentation:$multidexInstrumentationVersion",
                    'preference'             : "androidx.legacy:legacy-preference-v14:$androidXLegacyVersion",
                    'recyclerview'           : "androidx.recyclerview:recyclerview:$androidXRecyclerViewVersion",
                    'support'                : "androidx.legacy:legacy-support-v13:$androidXLegacyVersion"
            ],
            'test'        : [
                    'rules'     : "androidx.test:rules:$androidTestRulesVersion",
                    'testrunner': "androidx.test.ext:junit:$androidTestRunnerVersion",
                    'monitor'   : "androidx.test:monitor:$androidTestMonitorVersion",
                    'fragment'  : "androidx.fragment:fragment-testing:$androidFragmentTestVersion",
            ]
CaseyApptentive commented 4 years ago

Thanks for the thorough report, @astefanyuk !

Did you happen to start using Jetpack on the version of your app that's having issues? Wondering because we're currently tracking a similar issue related to compatibility with Jetpack.

astefanyuk commented 4 years ago

Jetpack are in both versions. android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx5120m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 org.gradle.parallel=true org.gradle.configureondemand=true kapt.incremental.apt=true org.gradle.caching=true

astefanyuk commented 4 years ago

@CaseyApptentive Do you have plans migrate to AndroidX ? Maybe it will resolve issue.

weeeBox commented 4 years ago

@astefanyuk, we have migrated to Android X. Unfortunately, this did not resolve the issue

weeeBox commented 4 years ago

@astefanyuk, we believe we have found a workaround. Preparing the fix...

weeeBox commented 4 years ago

Fixed in 5.4.5