Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. Upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. This Java library allows to easily integrate with Cloudinary in Java applications.




Cloudinary Android SDK

Build Status


The Cloudinary Android SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize and transform your cloud's assets.

Additional documentation

This Readme provides basic installation and usage information. For the complete documentation, see the Android SDK Guide.

Table of Contents

Key Features

Version Support

Cloudinary SDKAndroid SDK
2.x> 19
1.x> 14


Gradle Integration

Add the following dependency to your build.gradle:

implementation 'com.cloudinary:cloudinary-android:2.8.0'

Other Options

The cloudinary_android library is available in Maven Central. To use it, add the following dependency to your pom.xml:


Download the latest cloudinary-android from here and the latest cloudinary-core from here and put them in your libs folder.



Each request for building a URL of a remote cloud resource must have the cloud_name parameter set. You can set the cloud_name parameter either when initializing the library, or by using the CLOUDINARY_URL meta-data property in AndroidManifest.xml.

The entry point of the library is the MediaManager object. MediaManager.init() must be called before using the library, preferably in Application.onCreate(). Here's an example of setting the configuration parameters programmatically in your Applicaion.onCreate(:

 Map config = new HashMap();
 config.put("cloud_name", "myCloudName");
 MediaManager.init(this, config);

Alternatively, you can use the meta-data property. In that case, no configuration is required:


Only the cloud_name should be included. Your API key and secret aren't necessary. Note: Your API secret should never be exposed in the application.

        <meta-data android:name="CLOUDINARY_URL" android:value="cloudinary://@myCloudName"/>

Transforming and Optimizing Assets

Any image uploaded to Cloudinary can be transformed and embedded using powerful view helper methods:

The following example generates the url for accessing an uploaded sample image while transforming it to fill a 100x150 rectangle:

MediaManager.get().url().transformation(new Transformation().width(100).height(150).crop("fill")).generate("sample.jpg")

Another example, embedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:

MediaManager.get().url().transformation(new Transformation().width(90).height(90).crop("thumb").gravity("face")).generate("woman.jpg")

If your application is written in Kotlin you can use the syntax below:


You can provide either a Facebook name or a numeric ID of a Facebook profile or a fan page.

Embedding a Facebook profile to match your graphic design is very simple:

MediaManager.get().url().type("facebook").transformation(new Transformation().width(130).height(130).crop("fill").gravity("north_west")).generate("billclinton.jpg")

Uploading Assets

The entry point for upload operations is the MediaManager.get().upload() call. All upload operations are dispatched to a background queue, with a set of fully customizable rules and limits letting you choose when each upload request should actually run. Requests are automatically rescheduled to be retried later if a recoverable error is encountered (e.g. network disconnections, timeouts).

The upload results are dispatched asynchronously using UploadCallback. Global callbacks can be defined, as well as specific callbacks per request. Note: In order to receive global callbacks even when the app is already shut down, or in the background, the ListenerService class can be extended and registered in the manifest (see the class for further instructions).

The following examples uploads a File using the default settings, a request upload callback, and an upload preset (more about upload presets below):

String requestId = MediaManager.get().upload(imageFile).unsigned("sample_preset").callback(callback).dispatch();

The returned requestId is used to identify the request in global callbacks and to cancel the request if needed. The callback should be any implementation of UploadCallback.

The uploaded image is assigned a randomly generated public Id. As soon as onSuccess is called, the image is immediately available for download through a CDN:


You can also specify your own public ID:

String requestId = MediaManager.get().upload(uri).unsigned("sample_preset").option("public_id", "sample_remote").dispatch();

Using RequestUploadPolicy, an upload request can be configured to run under specific circumstance, or within a chosen time window:

The following examples uploads local Uri resource, configured to run immediately (the default), with a maximum of 7 retries, and only on an unmetered network (e.g. wifi):

String requestId = MediaManager.get().upload(uri)
    .policy(new RequestUploadPolicy.Builder().maxRetries(7).networkPolicy(RequestUploadPolicy.NetworkType.UNMETERED).build())

For security reasons, mobile applications cannot contain the full account credentials, and so they cannot freely upload resources to the cloud. Cloudinary provides two different mechanisms to enable end-users to upload resources without providing full credentials.

1. Unsigned uploads using Upload Presets.

You can create an upload preset in your Cloudinary account console, defining rules that limit the formats, transformations, dimensions and more. Once the preset is defined, it's name is supplied when calling upload. An upload call will only succeed if the preset name is used and the resource is within the preset's pre-defined limits.

The following example uploads a local resource, available as a Uri, assuming a preset named 'sample_preset' already exists in the account:

String requestId = MediaManager.get().upload(uri).unsigned("sample_preset").dispatch();
2. Signed uploads with server-based signature

Another way to allow uploading without credentials is using signed uploads. It is recommended to generate the upload authentication signature on the server side, where it's safe to store the api_secret.

Cloudinary's Android SDK allows providing server-generated signature and any additional parameters that were generated on the server side (instead of signing using api_secret locally).

Your server can use any Cloudinary libraries (Ruby on Rails, PHP, Python & Django, Java, Perl, .Net, etc.) for generating the signature. The following JSON in an example of a response of an upload authorization request to your server:

  "signature": "sgjfdoigfjdgfdogidf9g87df98gfdb8f7d6gfdg7gfd8",
  "public_id": "abdbasdasda76asd7sa789",
  "timestamp": 1346925631,
  "api_key": "123456789012345"

When initializing MediaManager, a SignatureProvider can be sent. Whenever an upload requires signing, the library will call the provider's provideSignature() method, where you should implement the call to your server's signing endpoint. This callback runs on a background a thread so there's no need to handle threading:

MediaManager.init(this, new SignatureProvider() {
    public Signature provideSignature(Map options) {
        // call server signature endpoint
}, null);


See contributing guidelines.

Get Help

If you run into an issue or have a question, you can either:

About Cloudinary

Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.

Additional resources


Released under the MIT license.


Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc