0

I created an app which uses native codes, when I compile it Android Studio in debug type app works perfectly but when I generate a signed aab file, the jniLibs files get compressed and it breaks functionality in the app. I would like to know if I can exclude the lib files from being compressed.

This is my project build.gradle

 buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
     
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url "https://dl.bintray.com/yahoo/maven/" }
        //maven { url "https://repo1.maven.org/maven2/" }
        maven { url "https://repo.spring.io/plugins-release/" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

This is my app build.gradle

    apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


android {


    compileSdkVersion 32
    buildToolsVersion "30.0.2"

    defaultConfig {

        applicationId "com.xxxxx.xxxxxxx"
        minSdkVersion 21
        targetSdkVersion 32
        versionCode 1
        versionName "1.0"

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

dependencies {
    implementation files('libs/achartengine-1.2.0.jar')
    api 'com.android.support:cardview-v7:25.+'
    api 'com.android.support:appcompat-v7:25.+'
    api 'com.android.support:preference-v7:25.+'
    api 'com.android.support:design:25.+'

These are the lib files when the app is compiled in debug type:

Original lib files

Lib files when I generate signed aab in android studio:

aab lib files

In debug build the app works perfectly.

In signed generated aab, the libs are compressed, as seen in the second screenshot, this breaks the libpdnsd.so and libtun2socks.so. This is the result

If there is a way to maintain the original libs when generating aab please let me know. Any solution is welcomed.

Rightplay
  • 1
  • 1

1 Answers1

0

You just not linked the lib folder to your app App (build.gradle). And also you have to add this line android:extractNativeLibs="true" to your AndroidManifest.xml

You can do it following like this.

  1. First add this to your AndroidManifest.xml
android:extractNativeLibs="true"
  1. Link the lib folder to your App (build.gradle)
android {
    sourceSets {
        all {
            jniLibs.srcDirs = ["lib"]
        }
    }
}
  1. Sync it
Anubis94
  • 149
  • 2
  • 7