Skip to main content

VPNGN In-App SDK for Android


  1. Download the VPNGN SDK for Android from the Downloads page

  2. Unarchive the file and place vpnsdk-release.aar in the libs folder of your project

  3. Add the following dependencies to build.gradle:

    implementation fileTree(include: ['vpnsdk-release.aar'], dir: 'libs')
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation ''
implementation 'androidx.webkit:webkit:1.4.0'
  1. Create notification icon asset

  2. Add manifest placeholders into the defaultConfig section of build.gradle:

    manifestPlaceholders = [
"VPN_NOTIFICATION_ICON" : "ic_stat_name"

VPN_NOTIFICATION_ICON should be set to the name of icon asset created before

  1. Add permissions to the AndroidManifest
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
  1. Add Wireguard service reference to AndroidManifest:
android:name="" />
  1. Add the following line to
  1. Add the following property to application tag in AndroidManifest:


Use the VPNGN.start method in order to start VPNGN activity:

    public static void start(@NotNull android.content.Context context,
@Nullable String subdomain,
String shortToken,
@Nullable VPNGN.OnError errorHandler)


  1. context - Current activity context

  2. subdomain - project subdomain

  3. shortToken - short token for the end-user

  4. errorHandler - callback to be invoked in case of error

    VPNGN.OnError interface has a following definition:
public interface OnError {
void onError();

Invocation of start method will lead to showing new activity. The previous activity will be shown when the end-user closes the activity.


    VPNGN.start(context, subdomain, token, new VPNGN.OnError() {
public void onError() {
Toast.makeText(MainActivity.this, "Error happened", Toast.LENGTH_LONG).show();

Traffic Counter (optional)

Call the VPNGN.setIOCounter method before calling VPNGN.start:

    VPNGN.setIOCounter(OnIOCount ioCounterHandler)


    VPNGN.setIOCounter(new VPNGN.OnIOCount() {
public void OnCount(long bytesIn, long bytesOut) {
// your code here