0

I created a VPN App and it is working correctly in Release and Debug APK files but when I upload it to Play Store, and then downloaded from Play Store it does not connect to the server and say "no process running" and give me the below error:

CANNOT LINK EXECUTABLE "/data/user/0/com.sharptech.sharpvpn/cache/c_pie_openvpn.arm64-v8a": library "libopenvpn.so" not found
pid: 3736, tid: 3736, name: c_pie_openvpn.a  >>> /data/user/0/com.sharptech.sharpvpn/cache/c_pie_openvpn.arm64-v8a <<<
Abort message: 'CANNOT LINK EXECUTABLE "/data/user/0/com.sharptech.sharpvpn/cache/c_pie_openvpn.arm64-v8a": library "libopenvpn.so" not found'

My Gradle Build is below:

    plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.sharptech.sharpvpn"
        minSdk 21
        targetSdk 32
        versionCode 8
        resConfigs "en"
        versionName "1.7"
        android.defaultConfig.ndk.debugSymbolLevel = 'FULL'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    buildFeatures {
        dataBinding true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation project(path: ':vpnLib')
        implementation platform('com.google.firebase:firebase-bom:31.0.1')
        implementation 'androidx.appcompat:appcompat:1.5.1'
        implementation 'com.google.android.material:material:1.7.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
        implementation 'com.google.firebase:firebase-analytics:21.2.0'
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
        implementation 'com.airbnb.android:lottie:5.2.0'
        implementation 'com.squareup.retrofit2:retrofit:2.9.0'
        implementation 'com.github.bumptech.glide:glide:4.14.2'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
        implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
        implementation 'com.android.ndk.thirdparty:openssl:1.1.1l-beta-1'
        //ads
        //implementation 'com.google.android.gms:play-services-ads:21.3.0'
        //implementation 'com.google.ads.mediation:applovin:11.5.2.0'
        //implementation 'com.google.ads.mediation:facebook:6.11.0.1'
    }

And I also use a vpnlib module which build.gradle file is:

apply plugin: 'com.android.library'
android {
    compileSdk 32

    defaultConfig {
        minSdk 21
        targetSdk 32
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    namespace 'de.blinkt.openvpn'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
}

3 Answers3

2

It looks like your app is expecting the library libopenvpn.so to be extracted at installation time (which is usually the case with debug APKs), however this doesn't have to happen. Play takes advantage of some available Android optimizations that allow the app to read the .so file directly from the APK to save space on the device. You should thus rely on Android APIs to load the .so file.

You can read more about this on this answer https://stackoverflow.com/a/56551499/4265103 which explains the proper way to load .so files or how to disable the optimization altogether.

Pierre
  • 15,865
  • 4
  • 36
  • 50
  • Your answer is really helpful and it finished my 3 weeks debugging and checking my app. The link you given is really helpful and I got information from there. – Rafiqullah Taibzada Oct 25 '22 at 16:31
2

I solved my problem by @Pierre's answer by adding the below code in application build.gradle file, inside android section and it solved my problem.

packagingOptions {
    jniLibs {
        useLegacyPackaging = true
    }
}
Arvin Rokni
  • 479
  • 5
  • 16
0
  1. In your app's build.gradle file add:

     bundle {
         abi { enableSplit = false }
     }
    
  2. In the file gradle.properties add :

android.bundle.enableUncompressedNativeLibs=false

  1. You can use bundletool to get the .apk file => install it on your computer to see the function in action. Generate Apk file from aab file (android app bundle)
xamxier
  • 1
  • 1