Last updated: Mar-01-2023
Cloudinary's Kotlin SDK provides simple, yet comprehensive image and video transformation, optimization, and delivery capabilities that you can implement using code that integrates seamlessly with your existing Kotlin or Java application.
- Uses Cloudinary's new SDK action based syntax with enhanced code autocomplete.
- Actions and transformations are immutable, for easier and safer code reuse.
- Makes use of Type-Safe Builders to create a Cloudinary DSL layer. The transformation syntax is therefore simpler and more human-readable when compared with the existing Java or Android SDKs.
Install and configure the SDK in your project to get started.
Add Kotlin SDK dependency
Add the SDK to your project as a dependency, we recommend using a build management tool such as Maven or Gradle to do this.
Add the Cloudinary Kotlin SDK to the dependencies section of your
Add the Cloudinary Kotlin SDK to the list of dependencies in your
Add your Cloudinary configuration
Cloudinary class is the main entry point for using the library. Your
cloud_name is required to create an instance of this class. Your
api_secret are used to perform secure API calls to Cloudinary (e.g., image and video uploads). Setting the configuration parameters can be done either programmatically using an appropriate constructor of the Cloudinary class or globally using an environment variable. You can find your configuration credentials in the Programmable Media Dashboard of the Cloudinary Console.
In addition to the required configuration parameters, you can define a number of optional configuration parameters if relevant.
Here's an example of setting configuration parameters in your Kotlin application:
Here is a simple example for generating a Cloudinary image URL, including a resize transformation, using the Kotlin SDK:
- See all possible transformations in the Transformation URL API reference.
- See more examples of image and video transformations using the Cloudinary Kotlin library.
Thanks for your time!
Migration from Java/Android
To use the Kotlin SDK with your existing Java and Android projects, we recommend adding your own Kotlin classes as a bridge between our SDK and your Java code. You can therefore take advantage of the simpler transformation building syntax.
For example, here's a simple Kotlin transformation:
And the corresponding code in Java:
You can add a new Kotlin file to act as a bridge e.g.:
You can then call this specific function from your Java code:
- See examples of powerful image and video transformations using Kotlin code
and see our image transformations and video transformations docs.
- Stay tuned for updates, tips and tutorials in Product Updates and Blog Posts.
- Take a look at our Android SDK as an alternative for Android development with Cloudinary.