# OpenVPN transport

## Configuring OpenVPN transport support on Android

If your Android project meets the following conditions:

* Target SDK is 29 or higher
* Uses [Google App Bundle](https://developer.android.com/guide/app-bundle) for application distribution

Then you need to add the following line to your `gradle.properties` file to ensure OpenVPN transport works on Android 10 (Q) (API 29) and later versions:

<figure><img src="/files/2je0BsjRGYyzSiJJAATT" alt=""><figcaption></figcaption></figure>

```
android.bundle.enableUncompressedNativeLibs=false
```

If you are not using Google App Bundle for your application distribution, you can skip this step, as it is not required.

## Adding OpenVPN transport support

1. To add support for OpenVPN, you need to include both the core SDK and OpenVPN transport SDK in your `build.gradle` file:

```groovy
dependencies {
    implementation 'co.pango:sdk-core:{VERSION_NAME}'
    implementation 'co.pango:sdk-openvpn:{VERSION_NAME}'
}
```

* `sdk-core`: This is the core VPN SDK.
* `sdk-openvpn`: This adds OpenVPN support to your app.

2. Need to modify `AndroidManifest.xml` so android properly extract OpenVpn binnaries

Add `android:extractNativeLibs="true"` to `application` tag:

```xml
...
<application
...
android:extractNativeLibs="true"
...
>
...
```

3\. When starting a VPN session, you can specify which transport protocol to use (Hydra or OpenVPN). Here’s how to specify OpenVPN (TCP) when starting the VPN:

```java
UnifiedSdk sdk = UnifiedSdk.getInstance(clientInfo);
SessionInfo session = new SessionConfig.Builder()
                .withLocation(UnifiedSDK.COUNTRY_OPTIMAL)
                .withReason(TrackingConstants.GprReasons.M_UI)
                .withTransport(OpenVpnTransport.TRANSPORT_ID_TCP)
                .build();
sdk.getVpn().start(session, new CompletableCallback() {
    @Override
    public void complete() {

    }

    @Override
    public void error(@NonNull VpnException e) {

    }
});
```

* `SessionConfig.Builder()`: Creates a configuration for the VPN session.
* `withLocation()`: Specifies the VPN location (e.g., COUNTRY\_OPTIMAL selects the best available server).
* `withReason()`: Provides a reason for starting the VPN session (for analytics purposes).
* `withTransport()`: Specifies the transport protocol to be used (OpenVPN TCP in this case).
* `sdk.getVpn().start()`: Starts the VPN session with the specified configuration.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pango.gitbook.io/paas/sdk/vpn-sdk-for-android/features/openvpn-transport.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
