APK generation resizes .so file

In apk, I use the aar library, which includes my own library. Trying to calculate the MD5 checksum of the .so file at runtime, I noticed that it is different from the .so file inside aar. The file size also changes: a file in apk weighs about 20 bytes. Does anyone know why the apk generation process modifies such files? Is there anything I can do to keep the file intact?

This only happens for arm64 version.

+4
source share
1 answer

In my app / build folder, I saw that the .so file is also between / transforms / mergeJniLibs and intermediate / transforms / stripDebugSymbol. The md5sum of the .so file in mergeJniLibs corresponds to the original amount of the .so file. The md5sum of the .so file in stripDebugSymbol was the one that was different. Further research forced me to add this to the android section of the build.gradle module (see also: PackagingOptions doNotStrip documentation ):

android {
    .
    .
    packagingOptions {
        doNotStrip "**/*.so"
    }
    .
}

After gradle synchronization, cleaning and rebuilding, md5sum.so in app / build / output / apk / debug corresponds to the original md5sum.

0
source

Source: https://habr.com/ru/post/1683422/


All Articles