on ‎2022 Apr 05 12:46 PM
In our current android app scenario want to sync local data to cloud after every 15 mins. For doing the same we are using android WorkManager with periodic work request. Its working fine if app is in foreground and being used by user. But same thing is not working when app is not in foreground. Ideally this approach should work in case of android but don't know why this is not working while syncing data to SAP cloud using its android SDK. Its failing in SAP SDK DataService class somewhere its using Android AsyncTask.
- Attaching firebase Crashlytics snapshot with datasync-failing-background.png
- App is having below SAP android dependencies and code snippets along with crash logs
sap_sdk_version = '3.2.0'<br>implementation "com.sap.cloud.android:foundation:$sap_sdk_version"<br>implementation "com.sap.cloud.android:odata:$sap_sdk_version"<br>implementation "com.sap.cloud.android:offline-odata:$sap_sdk_version"<br>implementation "com.sap.cloud.android:onboarding:$sap_sdk_version"<br>implementation "com.sap.cloud.android:onboardingflows-oauth:$sap_sdk_version"<br>implementation "com.sap.cloud.android:onboardingflows-storemanager:$sap_sdk_version"<br>implementation "com.sap.cloud.android:onboardingflows-logging:$sap_sdk_version"
// API used to sync local data with cloud<br>var service: SAPProxyClasses<br>service.applyChangesAsync( changeset,{<br>// Success callback<br>},<br>{ exeception -><br> // Failure callback<br>}<br>
// Crash logs (DataService from SAP android sdk)<br> at com.sap.cloud.mobile.odata.DataService$1.onPostExecute(DataService.java:189)
at android.os.AsyncTask.finish(AsyncTask.java:771)
at android.os.AsyncTask.access$900(AsyncTask.java:199)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8587)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Guys, could you please suggest us some solution/pointer to solve this problem?
Is there any way to achieve periodic data sync using SAP android SDK without such problem i.e. syncing data to SAP cloud while app is in background.
Request clarification before answering.
If the OData backend is being accessed via SAP Mobile Services and if the root cause of failure was server-side then you might checkk out Mobile Services Cockpit (Analytics -> Logs) or enable the Network Trace feature to capturre a HAR file for analysis.
On the client side, using Exception.getMessage() or Exception.getLocalizedMessage() doesn't include the exception class name or stack trace. Exception.toString() in general is better as at least the exception class name is included.
Use the 3-arg variant of Log.d (pass 'it' as the 3rd param) so you can get the full exception details including stack trace.
static intd(String tag, String msg, Throwable tr)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Presumably the "Failure callback" gets invoked with a non-null exception parameter (let's call it 'error')
Minimally:
error.printStackTrace()
Presumably this will print the exception information to the "Logcat" in Android Studio.
From there the issue could be diagnosed further.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have already logged the exception message there is no much information in exception message, its having only Url pointing to cloud
// Statement used to log this
Log.d("Synced", "failed, ${it.localizedMessage}")
// Exception received form SAP SDK as
Syncing trace failed, https://mobile-xxxxxxx.ap1.hana.ondemand.com
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.