4

I'm trying to build an Android application which contains native code using NDK. I'm using cmake as that appears to be the preferred build system for native code. The build fails during linking and I get the following message for a prebuilt library I link against: "error adding symbols: File in wrong format". Looking at the toolchain being used it's using mips64el-linux-android-4.9. Calling objdump on the library shows the format as "file format elf64-x86-64" which is what I want. How do I tell Android Studio to build the application for x86_64 so that it uses the correct toolchain? I tried adding the following to the build.gradle file for my application but this didn't change anything:

splits {
    abi {
        enable true
        reset()
        include "x86_64"
    }
}
imb
  • 137
  • 2
  • 7

1 Answers1

7

After more experimenting I was able to get this to work by adding an ndk block with an abiFilters attribute to my buildTypes. For example:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        ndk {
            abiFilters "x86_64"
        }
    }
    debug {
        ndk {
            abiFilters "x86_64"
        }
    }
}
imb
  • 137
  • 2
  • 7