Open TomislavHorvat1 opened 1 year ago
Hi there @TomislavHorvat1, the error you're encountering indicates that there is a type mismatch when passing the Transformation
object as an option in the Cloudinary upload request.
To resolve this issue, you can try the following steps:
Transformation
class from the Cloudinary SDK. It should be com.cloudinary.Transformation
.val transformation
declaration to remove the generic type parameter. Simply use val transformation = Transformation()
.TRANSFORMATION
option in the upload request, convert the transformation
object to a string using the toString()
method. Update the option line as follows:
.option(TRANSFORMATION, transformation.toString())
Here's the updated code snippet for reference:
val transformation = Transformation()
MediaManager.get().upload(uri)
.option(TRANSFORMATION, transformation.toString())
.option(SIGNATURE, photoSignature.signature)
.option(TIMESTAMP, photoSignature.timestamp)
.option(PUBLIC_ID, photoSignature.publicId)
.option(TAG, tag)
.callback(object : UploadCallback {
// ...
})
.dispatch()
Please give this a try, and let me know if you encounter any further issues.
Describe the bug in a sentence or two.
I get an
java.lang.ClassCastException: com.cloudinary.Transformation cannot be cast to java.lang.String
error when attempting a transformation:val transformation = Transformation<Transformation<*>>().width(1280).crop("scale")
Issue Type (Can be multiple)
[ ] Build - Can’t install or import the SDK [ ] Performance - Performance issues [x] Behaviour - Functions aren’t working as expected (Such as generate URL) [x] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)
Steps to reproduce
Error screenshots or Stack Trace (if applicable)
java.lang.ClassCastException: com.cloudinary.Transformation cannot be cast to java.lang.String at com.cloudinary.Util.buildUploadParams(Util.java:63) at com.cloudinary.Uploader.buildUploadParams(Uploader.java:51) at com.cloudinary.Uploader.uploadLargeParts(Uploader.java:160) at com.cloudinary.Uploader.uploadLarge(Uploader.java:149) at com.cloudinary.android.DefaultRequestProcessor.doProcess(DefaultRequestProcessor.java:223) at com.cloudinary.android.DefaultRequestProcessor.processRequest(DefaultRequestProcessor.java:87) at com.cloudinary.android.MediaManager.processRequest(MediaManager.java:441) at com.cloudinary.android.AndroidJobStrategy$UploadJob.doWork(AndroidJobStrategy.java:163) at androidx.work.Worker$1.run(Worker.java:86) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)
Build System
[ ] Maven [x] Gradle [ ] Other (Specify)
Is the issue reproducible only on a specific device?
[x] No [ ] Yes (specify model + Android version + vendor build number, if applicable)
Versions and Libraries (fill in the version numbers)
Cloudinary Android SDK version 2.3.1 Android version - 33 Kotlin version - 1.8.10 JVM (of the dev environment) - 17 Gradle - 8.0