Skip to main content
You're viewing documentation for a previous version of this software.Switch to the latest stable version
VESDK/Android/Introduction

Getting Started

A quick guide on how to easily get started with the VideoEditor SDK for Android. Your kick-off to delight your users with top-notch editing capabilities.

This document guides you through the process of integrating the VideoEditor SDK into your Android application.

Update for AndroidX#

You are now able to use AndroidX without affecting our PhotoEditor SDK. Google provides a new build tools version which fixes the bug. So please use buildToolsVersion '29.0.2' or higher when you are using AndroidX.

Prerequisites#

The following software is required:

  • Mac OS X, Windows, or Linux
  • Android Studio 3.0+
  • Android Minimum SDK 18+ (Android 4.3.0 released 24 July 2013)
  • Gradle 3.0+
  • Android Build Tools 29.0.2+
  • Android Support Repository 28.0.0+
  • License*

*You will need a valid license file in order to use the VideoEditor SDK in your own application. You can request a trial license at here. As our example app comes bundled with its own license, you can use this right away, if you just want to take a quick look.

Supported Android versions#

The VideoEditor SDK supports Android 4.3.0+ API 18 as the minSdkVersion, but it must be compiled with compileSdkVersion and targetSdkVersion Level 28+ to support Android 9 and above.

Add your license file#

Before using any components of the VideoEditor SDK, you have to add your license file to your applications assets folder. The expected default name of the license file is "LICENSE". In order to change this, see licencePath option of PESDKConfig in your gradle file.

The license is digitally signed and can't be altered without becoming invalid. Our sample app comes with its own license, so you can try that right away. To try our SDK in your own app, you need to request a trial license that's bound to your bundle identifier. You can start a trial here and download your license file from your dashboard.

Once the license file has been added the application will validate its presence upon launch.

Setting up the workspace#

Please ensure that our artifactory repository is listed in your repositories in the project's build.gradle file:

// Add the PESDK repository and plugin dependency
buildscript {
repositories {
google()
gradlePluginPortal()
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
dependencies {
// Insert the latest SDK version number here. You will find it here https://github.com/imgly/pesdk-android-demo/releases
classpath 'ly.img.android.pesdk:plugin:7.6.5'
// Add the Kotlin plugin
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
}
}

You will also have to add the pesdk plugin and PESDKConfig into your module's build.gradle file:

// Apply the Android Plugin
apply plugin: 'com.android.application'
// Apply the IMGLYPlugin
apply plugin: 'ly.img.android.sdk'
// Apply Kotlin Plugin
apply plugin: 'kotlin-android'
// Configure the IMGLYPlugin
imglyConfig {
vesdk {
enabled true
licencePath 'vesdk_android_license'
}
// Define the modules you are need
modules {
// Add all the UI modules you are need
include 'ui:video-trim'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:frame'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:text-design'
// Add the serializer if you need
include 'backend:serializer'
// Add asset packs if you need
include 'assets:font-basic'
include 'assets:frame-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
}
}
// Do your Android Configurations... ex.
android {
/* Set the compileSdkVersion at 29 or greater and set the buildToolsVersion at '29.0.2' or greater.
* We can't provide support for Bugs, that are the result of older SDK versions.
*/
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
/*
* Replace with your App-ID and keep sure that it match with your license!
* @see http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename
*/
applicationId "my.domain.application"
/* Set the minimum supported SDK Version to 16 (Android 4.1.0) or higher */
minSdkVersion 16
/* Set the target SDK Version at minimum to 29 or higher */
targetSdkVersion 29
}
/* Set Java Language level to Java 1.8+ */
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

Sync your project with the Gradle files after every edit! For more information about Gradle, please take a look at the Android Developer Documentation

Android Permissions#

The VideoEditor SDK requires two permissions: The "Write access to external storage" and the "Camera" permission (if you include the Camera module). You can grant this permissions yourself otherwise the SDK will automatically grant these permissions

Please take a look at the hint in the next step in order to integrate the Android 6.0 permission request correct!

Integration#

If you want to open the video editor look at this example:

public class VideoEditorDemoActivity extends Activity implements PermissionRequest.Response {
// Important permission request for Android 6.0 and above, don't forget to add this!
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults);
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
public void permissionGranted() {}
@Override
public void permissionDenied() {
/* TODO: The Permission was rejected by the user. The Editor was not opened,
* Show a hint to the user and try again. */
}
public static int VESDK_RESULT = 1;
public static int GALLERY_RESULT = 2;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private VideoEditorSettingsList createVesdkSettingsList() {
// Create a empty new SettingsList and apply the changes on this referance.
VideoEditorSettingsList settingsList = new VideoEditorSettingsList();
// If you include our asset Packs and you use our UI you also need to add them to the UI,
// otherwise they are only available for the backend
// See the specific feature sections of our guides if you want to know how to add our own Assets.
settingsList.getSettingsModel(UiConfigFilter.class).setFilterList(
FilterPackBasic.getFilterPack()
);
settingsList.getSettingsModel(UiConfigText.class).setFontList(
FontPackBasic.getFontPack()
);
settingsList.getSettingsModel(UiConfigFrame.class).setFrameList(
FramePackBasic.getFramePack()
);
settingsList.getSettingsModel(UiConfigOverlay.class).setOverlayList(
OverlayPackBasic.getOverlayPack()
);
settingsList.getSettingsModel(UiConfigSticker.class).setStickerLists(
StickerPackEmoticons.getStickerCategory(),
StickerPackShapes.getStickerCategory()
);
// Set custom editor image export settings
settingsList.getSettingsModel(SaveSettings.class)
.setExportDir(Directory.DCIM, "SomeFolderName")
.setExportPrefix("result_")
.setSavePolicy(SaveSettings.SavePolicy.RETURN_ALWAYS_ONLY_OUTPUT);
return settingsList;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
openSystemGalleryToSelectAnVideo();
}
private void openSystemGalleryToSelectAnVideo() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,"video/*");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, GALLERY_RESULT);
} else {
Toast.makeText(
this,
"No Gallery APP installed",
Toast.LENGTH_LONG
).show();
}
}
private void openEditor(Uri inputImage) {
VideoEditorSettingsList settingsList = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
settingsList = createVesdkSettingsList();
} else {
Toast.makeText(this, "Video support needs Android 4.3", Toast.LENGTH_LONG).show();
return;
}
// Set input image
settingsList.getSettingsModel(LoadSettings.class).setSource(inputImage);
new VideoEditorBuilder(this)
.setSettingsList(settingsList)
.startActivityForResult(this, VESDK_RESULT);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK && requestCode == GALLERY_RESULT) {
// Open Editor with some uri in this case with an image selected from the system gallery.
Uri selectedImage = intent.getData();
openEditor(selectedImage);
} else if (resultCode == RESULT_OK && requestCode == VESDK_RESULT) {
// Editor has saved an Image.
EditorSDKResult data = new EditorSDKResult(intent);
Uri resultURI = data.getResultUri();
Uri sourceURI = data.getSourceUri();
// This adds the result and source image to Android's gallery
data.notifyGallery(EditorSDKResult.UPDATE_RESULT & EditorSDKResult.UPDATE_SOURCE);
Log.i("PESDK", "Source image is located here " + sourceURI);
Log.i("PESDK", "Result image is located here " + resultURI);
// TODO: Do something with the result image
// OPTIONAL: read the latest state to save it as a serialisation
SettingsList lastState = data.getSettingsList();
try {
new IMGLYFileWriter(lastState).writeJson(new File(
Environment.getExternalStorageDirectory(),
"serialisationReadyToReadWithPESDKFileReader.json"
));
} catch (IOException e) { e.printStackTrace(); }
} else if (resultCode == RESULT_CANCELED && requestCode == VESDK_RESULT) {
// Editor was canceled
EditorSDKResult data = new EditorSDKResult(intent);
Uri sourceURI = data.getSourceUri();
// TODO: Do something with the source...
}
}
}

Sample Application#

You can access the source code for our demo application from our demo repository.