Open frogoscar opened 2 months ago
Any kind help ? Thanks a lot~
Hi @frogoscar , thank you for your patience, our team will look into the issue
Hi @frogoscar, thanks for your patient. I started to look at this and have a question about how you're calling SubmitEvents. From the snippits you provided it looks like you're submitting Pinpoint events immediately after you initialize the Pinpoint client. So how I read your flow is:
App launch > Initialize Pinpoint > Submit local events > App has finished starting > Events are logged.
I don't know the full workings of the Pinpoint client yet but I'm wondering if you're attempting to submit the events too early and running into a race condition where on certain user's devices, the database client isn't fully initialized and thus ready for writes. The issue that you linked was explicitly found during unit testing so the scenario for encountering that issue is pretty different than the real-life scenario you're encountering.
Is there a reason you're trying to submit events so early/in the Application class? From documentation it looks like general best practice is to submit events at the end of the user's session. For cases of fatal recoveries, you can always try to submit events in some primary activity like your login, home, or similar activity.
Hi @frogoscar, thanks for your patient. I started to look at this and have a question about how you're calling SubmitEvents. From the snippits you provided it looks like you're submitting Pinpoint events immediately after you initialize the Pinpoint client. So how I read your flow is:
App launch > Initialize Pinpoint > Submit local events > App has finished starting > Events are logged.
I don't know the full workings of the Pinpoint client yet but I'm wondering if you're attempting to submit the events too early and running into a race condition where on certain user's devices, the database client isn't fully initialized and thus ready for writes. The issue that you linked was explicitly found during unit testing so the scenario for encountering that issue is pretty different than the real-life scenario you're encountering.
Is there a reason you're trying to submit events so early/in the Application class? From documentation it looks like general best practice is to submit events at the end of the user's session. For cases of fatal recoveries, you can always try to submit events in some primary activity like your login, home, or similar activity.
@vincetran @joon-won
Hi, thank you very much for your kind reply.
So maybe the reason is that I call submitEvents()
too early (like vincetran says) ?
So if I remove the code that calls submitEvents()
at Application 's onCreate()
, and put submitEvents()
in the code location in an Activity when the app switches from Foreground to Background (At that moment I think the database client is fully initialized and thus ready for writes), will it be ok ?
Thanks a lot!
That sounds more reasonable! If you take a look at the docs, there's an example that demonstrates that exact usecase (albeit written in Java): https://docs.amplify.aws/android/sdk/analytics/events/#reporting-session-events
Basically, when the app enters foreground, you call startSession()
and when it enters background, it calls both stopSession()
and submitEvents()
.
Hopefully that fixes your problem but at a higher level suggestion, we do recommend you migrate over to use the Amplify SDK at your earliest convenience.
That sounds more reasonable! If you take a look at the docs, there's an example that demonstrates that exact usecase (albeit written in Java): https://docs.amplify.aws/android/sdk/analytics/events/#reporting-session-events
Basically, when the app enters foreground, you call
startSession()
and when it enters background, it calls bothstopSession()
andsubmitEvents()
.Hopefully that fixes your problem but at a higher level suggestion, we do recommend you migrate over to use the Amplify SDK at your earliest convenience.
@vincetran Thanks a lot.
The calls of startSession()
and stopSession()
are not mandatory, right ?
I would like to use the new Amplify SDK for Android, of course.
But my Android app's minSdk is 21, while the latest Amplify SDK for Android (from version 2.0.0) requires Android minSdk >= 24).
I have some customs whose Android devices still use Android 5 (Android SDK 21) ~ Android 6 (Android SDK 23).
The latest version of Amplify SDK for Android that satisfies the condition of minSdk 21 is 1.38.8 (1.38.8 uses underlying version 2.73.0 of AWS SDK for Android ).
Currently I use version 2.75.0 of AWS SDK for Android.
In the future when I set my Android minSdk >= 24 , I will migrate to Amplify SDK for Android .
Describe the bug After integrating AWS Pinpoint Analytics into my Android app, I notice many crashes reported on my Google Play Console, as below :
This crash is encountered mostly when opening the Android app.
The log of this crash is likely the same to https://github.com/aws-amplify/aws-sdk-android/issues/2520 .
From the log, I can say the crash occurs when AWS Pinpoint calls method
submitEvents()
. Please look at my usage as below.I firstly initialize AWS (in an Kotlin object class named
AnalyticsUtils
'sinit()
method) Pinpoint Analytics Client as belowRecord an event as below
Submit all events recorded in local SQLite database when app is launched (in the
onCreate()
method of the inherited Application class) as belowpinpointSubmitEvents()
method is defined in AnalyticsUtils.ktCould you tell me if I use the Pinpoint SDK incorrectly, how can I fix this crash ? Or should I use the new Amplify SDK for Pinpoint Analytics instead ?
Thank you very much!
To Reproduce
The problem is that I can not reproduce this crash on my own physical Android device (which is OPPO K10x), it works fine. But when the Prod release is on Google Play, my users encounter crash, some users say that they encounter crash when opening my app.
Which AWS service(s) are affected? AWS Pinpoint
Expected behavior No crash.
Screenshots
Environment Information (please complete the following information):
com.amazonaws:aws-android-sdk-core:2.74.0
andcom.amazonaws:aws-android-sdk-pinpoint:2.74.0
. Not the new Amplify SDK )Additional context Add any other context about the problem here.