When using the OSS Android SDK for resumable upload, onSuccess fires normally after a successful upload, but onFailure is never called after a failure. The root cause is a nullable type mismatch in the onFailure method signature when writing the callback in Kotlin.
Diagnose the issue
Follow these steps to isolate whether the problem is in the SDK itself or in your integration.
Step 1: Test with the sample code in isolation.
Run the Android SDK resumable upload sample code locally, without integrating it into your project.
If
onFailurefires correctly in the isolated test, the SDK itself is working. The problem is in your project integration. Proceed to Step 2.
If
onFailurestill does not fire in the isolated test, check your SDK configuration.
Step 2: Check for Network Profiler interference.
In Android Studio, make sure no Network Profiler is active. The Network Profiler can intercept network traffic in ways that prevent error callbacks from being triggered.
Step 3: Fix the nullable type mismatch in Kotlin.
The OSS Android SDK does not have a Kotlin version — the SDK interface is Java-based. When implementing the onFailure callback in Kotlin, both exception parameters must be declared as nullable. If they are not, the method signature does not match the Java interface, and the callback is silently skipped.
The following examples show the incorrect and correct implementations:
Incorrect (callback silently skipped):
// Missing nullable markers — does not match the Java interface
onFailure(request: ResumableUploadRequest, clientExcepion: ClientException, serviceException: ServiceException)Correct (callback fires on failure):
onFailure(request: ResumableUploadRequest, clientExcepion: ClientException?, serviceException: ServiceException?)Both ClientException? and ServiceException? must use the ? suffix to match the Java interface.
Verify the fix
After updating the signature, trigger an upload failure and confirm that onFailure is now called.
Application scope
OSS