DeployGate SDK for Android

To use advanced feature of DeployGate, you need to integrate SDK into your app.
Just adding single line of code and it's done.

First note that you may use basic features of DeployGate without installing the SDK. Once you drop your current app package onto DeployGate, you may download it through DeployGate immediately, watch how installation is going on the dashboard and further app updates can also be pushed over the air.

Installing the DeployGate SDK into your project enables powerful features, such as crash reporting, remote LogCat and user authentication.

Since installing the DeployGate SDK is fairly simple, just adding a jar file and inserting a line to your application, we highly recommend to do so. DeployGate SDK functions are automatically disabled in release builds.

without SDK with SDK + permissions
Over the Air Deploy
Pushing Updates
Installation Reporting
Crash Reporting
App Boot Reporting
User Authorization
Kill Switch
Remote LogCat

Install for AndroidStudio


1. Edit build.gradle

Add following lines to the build.gradle file in your project.
repositories {
    mavenCentral()
}

dependencies {
    compile 'com.deploygate:sdk:3.1'
}

2. Click "Sync Project With Gradle Files" button of AndroidStudio.

Sync project with gradle files

Install for Eclipse


1. Download DeployGate SDK

Download SDK
DeployGate SDK supports the android-7 or higher.

2. Unzip it and copy deploygatesdk.jar into your project's libs directory.

Sdk drop into libs

Usage


1. Does your project have an Application class?

If your project has an Application class specified in <application android:name="classname" /> in your AndroidManifest.xml, open that class and add following line into onCreate() function:

DeployGate.install(this);

If you don't have an Application class, create App.java on your package root (for example, if your application package is org.example, create src/org/example/App.java) and add this:

package org.example;

import android.app.Application;
import com.deploygate.sdk.DeployGate;

public class App extends Application {
  @Override
  public void onCreate() {
      super.onCreate();
      DeployGate.install(this);
  }
}

Then add android:name attribute on <application> tag in AndroidManifest.xml.

<application
    android:name=".App"
    android:label="@string/app_name"
    android:icon="@drawable/ic_launcher"
    android:theme="@style/AppTheme">
DeployGate SDK will automatically disabled on the Release builds. (android:debuggable="false") If you want to use any feature of the DeployGate SDK on the Release builds, for example using Titanium Mobile, use DeployGate.install(this, null, true) instead of DeployGate.install(this).

2. That's it!

Let's build and push it. Now you are ready to receive boot and crash report. If you want to use Remote LogCat, continue proceeding to next section.

Sample Codes
The source code of sample app integrated with SDK is public on the GitHub.

Android 4.1 or higher On the devices running Android 4.1 (Jelly Bean) or higher, Remote LogCat works without adding the permission. However, for security reasons, you can only see the log produced by your app process.

DeployGate provides wireless LogCat mechanism called Remote LogCat. Once you choose the device to see logs from your dashboard, the request directed to the device then DeployGate client and SDK in your app receive and start transferring LogCat.

In order to collect LogCat lines from your app, you have to add some permission request on your AndroidManifest.xml.

Hint Crash reporting will work without this setting.

Alternative You don't need to change the setting if you use the logging mechanism of DeployGate

1. Open AndroidManifest.xml

2. Add following uses-permission declaration under your <manifest> definition.
<uses-permission android:name="android.permission.READ_LOGS" />

3. Rebuild your app and push it.

DeployGate SDK will automatically recognize this change and is ready to receive requests. You may see wireless LogCat working the devices on your app's dashboard page.

In some cases, you may want to restrict app distribution only to users you explicitly allowed.

Since app packages on the Android devices can be extracted by anyone, without root privileges, restricting file distribution itself is not enough to protect your app.

DeployGate SDK provides several functions to check if the user has a privilege to use your app, in other words, if the current DeployGate user has your app on the list.

DeployGate.isDeployGateAvailable()

Returns whether the DeployGate client app is installed.


DeployGate.isAuthorized()

Returns this app is in the current user's list (only if above is true.)


DeployGate.getLoginUsername()

Returns the current user's name (only if both above is true.)


DeployGate.getAuthorUsername()

Returns app's author (i.e. distributor) username. #install(Application, Username) is also available to ensure the distributor of the app.

You can send an arbitrary string as a log by calling DeployGate.logError(), DeployGate.logWarn(), DeployGate.logDebug(), DeployGate.logInfo() and DeployGate.logVerbose(). The log sent by this method will be shown on your timeline in realtime.

Tip: This will not require READ_LOGS permission so if you can log whatever you want with this way, you don't have to change your app manifest.

Heads Up Since there is no filtering mechanism available on the timeline in current, you should consider carefully how much events to log. This will be improved in near future.


Ask questions, share your tips or help others at our forum.