Search code examples
androidshared-librariesapkaarlibs

How to keep only armeabi in an apk when android studio creates this apk?


There are several third-party jars I have to use in my project.

At the first, each jar provides a .so file in app/src/main/jniLibs/armeabi directory.

After android studio run 'app', there was only an armeabi directory in app-debug.apk/lib, and every thing was OK.

However, since I imported an .aar to app/aars in my project, there were x86, x86_64, armeabi-v7a, arm64-v8a and armeabi directories in app-debug.apk/lib after adroid studio run 'app', and the app just broken when launched. After I manually deleted x86, x86_64, armeabi-v7a, arm64-v8a directories and keep only armeabi directory in app-debug.apk/lib. Then I installed the apk, every thing was OK again.

So I want to know how to keep only armeabi in an apk after android studio run 'app'?


Solution

  • I have solved my own question. The issue was caused by the new comer -- the .aar file.

    The solution is:

    step 1: open the .aar file with winRAR
    step 2: pull the .jar in the .aar file to app/libs directory
    step 3: pull the jni/armeabi/xxx.so in the .aar file to app/src/main/jniLibs/armeabi directory
    step 4: remove the .aar file in app/aars and relevant codes in app/build.gradle