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'
}
CodePudding user response:
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.
CodePudding user response:
I solved my problem by Pierre Answer. The way which solved my problems is:
I added the below code in my app build.gradle file inside android{
and it solved my problem.
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}