microsoft / appcenter-sdk-dotnet

Development repository for the App Center SDK for .NET platforms, including Xamarin
Other
311 stars 141 forks source link

NullPointer Exception on Android 12 on Resume #1701

Closed rogerbriggen closed 1 year ago

rogerbriggen commented 2 years ago

Description

We see crashed of our app because of appcenter sdk

Repro Steps

Please list the steps used to reproduce your issue.

  1. Currently, I only see the stacktrace on appcenter... but it seems if the app resumes

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.content.SharedPreferences.getBoolean(java.lang.String, boolean)' on a null object reference com.microsoft.appcenter.utils.storage.SharedPreferencesManager.getBoolean SharedPreferencesManager.java:68 com.microsoft.appcenter.AbstractAppCenterService.isInstanceEnabled AbstractAppCenterService.java:136 com.microsoft.appcenter.distribute.Distribute.registerReceiver Distribute.java:612 com.microsoft.appcenter.distribute.Distribute.onActivityResumed Distribute.java:550 android.app.Application.dispatchActivityResumed Application.java:430 android.app.Activity.dispatchActivityResumed Activity.java:1400 android.app.Activity.onResume Activity.java:1966 androidx.fragment.app.FragmentActivity.onResume FragmentActivity.java:434 android.app.Instrumentation.callActivityOnResume Instrumentation.java:1491 android.app.Activity.performResume Activity.java:8280 android.app.ActivityThread.performResumeActivity ActivityThread.java:4923 android.app.ActivityThread.handleResumeActivity ActivityThread.java:4972 android.app.servertransaction.ResumeActivityItem.execute ResumeActivityItem.java:60 android.app.servertransaction.ActivityTransactionItem.execute ActivityTransactionItem.java:45 android.app.servertransaction.TransactionExecutor.executeLifecycleState TransactionExecutor.java:176 android.app.servertransaction.TransactionExecutor.execute TransactionExecutor.java:97 android.app.ActivityThread$H.handleMessage ActivityThread.java:2345 android.os.Handler.dispatchMessage Handler.java:106 android.os.Looper.loopOnce Looper.java:233 android.os.Looper.loop Looper.java:344 android.app.ActivityThread.main ActivityThread.java:8210 java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:584 com.android.internal.os.ZygoteInit.main ZygoteInit.java:1034

Details

  1. What is your app platform (Xamarin.Android or Xamarin.iOS or UWP)?
    • MAUI (Android)
  2. If using Xamarin.Forms or if using portable/shared code to call our SDK APIs, are you using shared project, PCL code or .NET standard code for the application? Which .NET standard version or which PCL profile?
    • .Net 6
  3. Which SDK version are you using?
    • 5.0.0 Preview 1
  4. Which OS version did you experience the issue on?
    • Android 12
  5. What device version did you see this error on? Were you using an emulator or a physical device?
    • different physical phones (OnePlus 8T, Mi 9 SE, Galaxy S10, ...)
  6. What third party libraries are you using?
  7. Please enable verbose logging for your app using AppCenter.LogLevel = LogLevel.Verbose before your call to AppCenter.Start(...) and include the logs here:
aleksandr-dorofeev commented 2 years ago

Hello, @rogerbriggen, thanks for getting in touch with us! Unfortunately, we were unable to reproduce the behavior you described. Could you please provide repro steps and verbose logs.

rogerbriggen commented 2 years ago

Hi @aleksandr-dorofeev , I don't know the steps nor can I reproduce it mayself but I have these crashlogs in appcenter from our app. The crash was 17 times while we have maybe 10 testers... so it happens. But you can see in the stacktrace that the problem comes from appcenter distribute... so we have probably to get rid of it because it crashes our app.

aleksandr-dorofeev commented 2 years ago

Could you provide verbose logs in this case?

rogerbriggen commented 2 years ago

Sure. Where do I get then the output of these logs?

aleksandr-dorofeev commented 2 years ago

You can find the AppCenter logs in the output of your IDE.

rogerbriggen commented 2 years ago

Then I cannot. As I have written, the phones are not connected to my computer. It would be helpful if we could get a callback for the log entries or you support ILogger

aleksandr-dorofeev commented 2 years ago

Sorry for the misunderstanding. In this case, could you clarify how you launch the application? Do you use AppCenter tests?

rogerbriggen commented 2 years ago

No. We just use Crash, Analytics and Distribute in our app, otherwise we don't use any service of app center. The app is created with MAUI. Currently, I just see several crashes inside appcenter with the above stacktrace which means, that app center sdk is crashing my app. I also think, that the stack trace is quite clear, so catching the exception or checking for null inside the app center is appreciated. The other option is to disable app center distribute since the stack trace seems quite clear about it.

DmitriyKirakosyan commented 2 years ago

Hi @rogerbriggen , this looks like a duplicate of https://github.com/microsoft/appcenter-sdk-android/issues/1610 and https://github.com/microsoft/appcenter-sdk-android/issues/1645. It was fixed in https://github.com/microsoft/appcenter-sdk-android/pull/1622 and released in 4.5.3.

Based on your stack trace it looks like the version of AppCenter SDK is prior this fix ( < 4.5.3). Please check the versions of your app for these crashes. There should not be a version which uses SDK 4.5.3 or higher.

rogerbriggen commented 2 years ago

Hi @DmitriyKirakosyan As I have written, we use appcenter sdk 5.0.0 Preview 1... So, this is seems there is a regression

DmitriyKirakosyan commented 2 years ago

Version 5.0.0-preview.1 uses Android native SDK of version 4.5.5.

From your call stack:

com.microsoft.appcenter.distribute.Distribute.registerReceiver Distribute.java:612
com.microsoft.appcenter.distribute.Distribute.onActivityResumed Distribute.java:550

These lines are not relevant to the appcenter android sdk code of version 4.5.5. So, I'm confused how you ended up having this call stack with version 5.0.0-preview.1.

Have you ever published your app with AppCenter DotNet SDK of version 4.5.1 or lower?

Have you tried to identify the testers who face this crash? You can use setUserId API for that. Is it possible to contact them and ask to gather the app logs? Make sure you enabled verbose logging and published the app with this change.

MikhailSuendukov commented 1 year ago

I close this issue because of inactivity. Please feel to reopen it, in case problem still persist, or you have any questions.