0
  • Windows 10 home edition (Chinese)
  • Android Studio 3.0.1
  • Gradle 4.1

The steps:

  1. Create a new project with an android module.
  2. In android module, under "/src/main" directory, create "jniLibs/armeabi-v7a" folder, put any ".so" file(s) into it.
  3. Build project and generate ".apk" file.
  4. Open ".apk" file with Zip-Tools (Unzip ".apk" file), extract all files from the APK.
  5. Compare and check ".so" file. All of these ".so" files has been modified 3 bytes (near file tail), like '0x00' change to '0x04', '0x08' change to '0x12'.

Why the '.so' files in APK not equal original '.so' files?

NoSound
  • 25
  • 5

1 Answers1

0

I had the exact same problem as you. 3 bytes were different near the tail end of the .so that was packed in the .apk (app/build/outputs/apk/debug). The three bytes changed as follows:

  • 0x00 to 0x04
  • 0x04 to 0x00
  • 0x0a to 0x14 (the difference is the same as your byte changing from 0x08 to 0x12)

I was digging around in the app/build folder and I saw that the .so file was also located in intermediates/transforms/mergeJniLibs and intermediates/transforms/stripDebugSymbol. The md5sum of the .so file in mergeJniLibs matched the original .so file's sum. The md5sum of the .so file in stripDebugSymbol was the one that was different. Further investigation led me to add this to the android section of Module's build.gradle (see also: PackagingOptions doNotStrip documentation ):

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

After a Gradle sync, clean, and rebuild, the md5sum of the .so in app/build/outputs/apk/debug matches the original md5sum.