You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Open
1 task done
PavlosTze opened this issue
Jan 15, 2025
· 3 comments
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:
Create a failed request (e.g. close the internet before uploading)
Call startUpload again on this request
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)
@PavlosTze having also an automatic test for this, please check your app's lifecycle where you are starting the upload, this exception is thrown when you are starting the same upload twice. What is exactly "Manual retrying"? You should use the retry policy mechanism of the library instead.
@PavlosTze having also an automatic test for this, please check your app's lifecycle where you are starting the upload, this exception is thrown when you are starting the same upload twice. What is exactly "Manual retrying"? You should use the retry policy mechanism of the library instead.
We use the automatic retry policy, but we also have a "Retry" button when the upload fails, which the user can click, and based in your guide I posted above, I save the uploadId and the MultipartUploadRequest and I run startUpload again when that retry button gets clicked.
That guide is really old and maybe needs a refresh. It's been written before the persistent uploads feature and it covers only a bare minimum simple example. In your case you are attempting to retry an upload which is still in the execution phase and so the exception is correct. You can check the running tasks using the management APIs before attempting to start the upload.
Describe the bug
I followed your guide on Advanced topics mentioning:
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:
startUpload
again on this requestExpected behavior
To retry properly.
OS and Lib versions (please complete the following information):
Request code:
Where have you added the request code?
Debug Log:
Other info:
Project
The text was updated successfully, but these errors were encountered: