Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle + ndkbuild + android studio 2.2 how to set supported ABIs?

I want to use android studio integration with ndkbuild.

My "native" part of project build only for armeabi-v7a-hard and x86, and all works fine if I just run ndk-build in jni directory. I have proper lines in Application.mk:

APP_ABI := armeabi-v7a-hard x86

To integration project into android studio I added such lines into build.gradle:

externalNativeBuild {
    ndkBuild {
        path 'src/lib/jni/Android.mk'
    }
}

But for some reason gradle build try build native code with APP_ABI=armeabi and failed, because of my code can only be build with armeabi-v7a-hard.

So how can I tell gradle to build my code only for armeabi-v7a-hard and x86, or just not ignore APP_ABI line from Application.mk?

I try such variant:

defaultConfig {
    ndk {
      abiFilters 'x86', 'armeabi-v7a-hard'
    }
}

but gradle failed with such message:

ABIs [armeabi-v7a-hard] are not available for platform and will be excluded from building and packaging. Available ABIs are [armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64].

Note, that I use ndk 10, not last one (ndk 13), where there is armeabi-v7a-hard, and ndk.dir in local.properties to right value.

like image 219
fghj Avatar asked Dec 06 '16 11:12

fghj


People also ask

What is supported Abis?

Different Android devices use different CPUs, which in turn support different instruction sets. Each combination of CPU and instruction set has its own Application Binary Interface (ABI). An ABI includes the following information: The CPU instruction set (and extensions) that can be used.

Where is Gradle settings in Android Studio?

Open your project in Android Studio and select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle (Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle on a Mac).

Is NDK necessary for Android studio?

You do not need this component if you only plan to use ndk-build. LLDB: the debugger Android Studio uses to debug native code.


1 Answers

Link provided by @Titan is all you need to set the ABI.

The reason why it might not be working is because armeabi-v7a-hard is deprecated in 2015, so targeting it is resulting in this issue. You should target armeabi-v7a as per this this post

like image 159
Darpan Avatar answered Oct 14 '22 06:10

Darpan