Skip to content

RemoteServiceException when start TransferService from a Service #2471

Closed
@buntupana

Description

Describe the bug
Sometimes I get a RemoteServiceException starting TransferService from a Service. Cant reproduce the error because I got it from users, never experimented myself

The exception:

Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{6971a94 u0 com.example.app/com.amazonaws.mobileconnectors.s3.transferutility.TransferService}
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2240)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8512)
       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)

To Reproduce

val tsIntent = Intent(this, TransferService::class.java)                                  
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {                                     
    tsIntent.putExtra(TransferService.INTENT_KEY_NOTIFICATION, uploadNotification.build())
    tsIntent.putExtra(TransferService.INTENT_KEY_NOTIFICATION_ID, NOTIFICATION_ID)        
    tsIntent.putExtra(TransferService.INTENT_KEY_REMOVE_NOTIFICATION, true)               
    startForegroundService(tsIntent)                                                      
} else {                                                                                  
    startService(tsIntent)                                                                
    startForeground(NOTIFICATION_ID, uploadNotification.build())                          
}      

Which AWS service(s) are affected?
com.amazonaws:aws-android-sdk-s3

Expected behavior
Start the TransferService as usual

Environment Information (please complete the following information):

  • AWS Android SDK Version: 2.22.2
  • Device: Mostly Samsung
  • Android Version: > Oreo

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workings3Issues with the AWS Android SDK for Simple Storage Service (S3).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions