5

It appears that my libraries no longer exist in nativeLibraryDir after updating Gradle from 5.4.1 to 5.6.4 and Android Studio from 3.5.3 to 3.6.1. My current implementation for accessing my libraries is as follows:

File libDirectory = new File(context.getApplicationInfo().nativeLibraryDir);
String files[] = libDirectory.list();

Before the update, I can debug and see that the 'files' array contains a list of all my libraries as expected. After the update, the 'files' array appears empty.

I have analyzed my APK and confirmed that the libraries do exist in the package.

Am I retrieving the path in a poor fashion? Is there required permissions that I am not aware of? I am using CMake to build my libraries:

externalNativeBuild {
    cmake {
        path '../../../common/CMakeLists.txt'
    }
}

Using NDK version 21.0.6113669

Update: Reverting to NDK r19c produces the same results

Update: libDirectory resolves to /data/app/com.example.application-1/lib/arm before and after the update

Update: setting android.useNewApkCreator=false in gradle.properties produces the same result

Update: Using the Device File Explorer, I am able to view the libraries within the lib/arm/ folder prior to the update. After the update, the lib/arm/ folder is still the same size (4KB), but I am no longer able to view the content within the folder. Folder permissions appear to be unchanged.

Brendan Cordingley
  • 190
  • 1
  • 4
  • 20

2 Answers2

7

I also encountered this problem, and I finally solved it by :

// AndroidManifest.xml
<application
  ...
  android:extractNativeLibs="true"  
  ...
>

when extractNativeLibs set to true, so files copy to lib/xxx folder.

fengma
  • 161
  • 1
  • 6
  • alse see: https://stackoverflow.com/questions/42998083/setting-androidextractnativelibs-false-to-reduce-app-size/47541129 – fengma Nov 17 '20 at 08:46
-2

use this version

dependencies {
    classpath 'com.android.tools.build:gradle:3.6.0'

}

with Gradle 5.6.4

Katana
  • 752
  • 4
  • 23