Skip to content

App Crashed on manual retrying with: java.lang.IllegalStateException: You have already called startUpload() on this Upload request instance once and you cannot call it multiple times. Check your code. #672

Closed
@PavlosTze

Description

@PavlosTze

Describe the bug
I followed your guide on Advanced topics mentioning:

So, what I suggest you to do is to keep a reference to the uploadID and the upload request object somewhere in your code, so you can trigger upload again by calling the startUpload method on the request object when certain conditions (e.g. server is reachable again) are met.

But I got a crash with a following message:
java.lang.IllegalStateException: You have already called startUpload() on this Upload request instance once and you cannot call it multiple times. Check your code.

To Reproduce
Steps to reproduce the behavior:

  1. Create a failed request (e.g. close the internet before uploading)
  2. Call startUpload again on this request
  3. See error

Expected behavior
To retry properly.

OS and Lib versions (please complete the following information):

  • Android Upload Service version: 4.9.3
  • Android version and API version: Android 14
  • HTTP stack: OkHttpStack

Request code:

            val request = repository.getUploadIdRequest(it)
            request?.setUploadID(it)
            request?.startUpload()

Where have you added the request code?

  • Activity

Debug Log:

java.lang.IllegalStateException: You have already called startUpload() on this Upload request instance once and you cannot call it multiple times. Check your code.
                                                                                                    	at net.gotev.uploadservice.UploadRequest.startUpload(UploadRequest.kt:68)
                                                                                                    	at com.weatherxm.usecases.DevicePhotoUseCaseImpl.retryUpload(DevicePhotoUseCase.kt:73)
                                                                                                    	at com.weatherxm.ui.devicesettings.BaseDeviceSettingsViewModel.retryPhotoUpload(BaseDeviceSettingsViewModel.kt:218)
                                                                                                    	at com.weatherxm.ui.devicesettings.wifi.DeviceSettingsWifiActivity.onPhotos$lambda$19(DeviceSettingsWifiActivity.kt:201)
                                                                                                    	at com.weatherxm.ui.devicesettings.wifi.DeviceSettingsWifiActivity.$r8$lambda$kSy6cgZ6VJazm_Axn4tj6VuaazI(Unknown Source:0)
                                                                                                    	at com.weatherxm.ui.devicesettings.wifi.DeviceSettingsWifiActivity$$ExternalSyntheticLambda19.invoke(D8$$SyntheticClass:0)
                                                                                                    	at com.weatherxm.ui.devicesettings.DevicePhotosView.setOnClickListener$lambda$4(DevicePhotosView.kt:87)
                                                                                                    	at com.weatherxm.ui.devicesettings.DevicePhotosView.$r8$lambda$rQcjTDg3INNsRE1dQ_yDaZrhtwk(Unknown Source:0)
                                                                                                    	at com.weatherxm.ui.devicesettings.DevicePhotosView$$ExternalSyntheticLambda5.onClick(D8$$SyntheticClass:0)
                                                                                                    	at android.view.View.performClick(View.java:8047)
                                                                                                    	at android.widget.TextView.performClick(TextView.java:17792)
                                                                                                    	at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1218)
                                                                                                    	at android.view.View.performClickInternal(View.java:8024)
                                                                                                    	at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
                                                                                                    	at android.view.View$PerformClick.run(View.java:31890)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                    	at android.os.Looper.loop(Looper.java:319)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8919)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Other info:
Project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions