I have removed mips, but am still getting the warning
Error:(81) Android NDK: Application targets deprecated ABI(s): mips64
Error:(82) Android NDK: Support for these ABIs will be removed in a future NDK release.
Error:(82) Android NDK: Support for these ABIs will be removed in a future NDK release.
Error:(81) Android NDK: Application targets deprecated ABI(s): mips
Application.mk
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-10
UPDATES
build.gradle for ndk
sourceSets.main.jni.srcDirs = []
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
I fixed the problem by adding:
android {
.
.
versionName "1.0"
ndk {
abiFilters 'x86'
abiFilters 'armeabi-v7a'
moduleName "your-library-name"
}
to the app/build.gradle
It appears that Android Studio was not removing the previous cached NDK builds from the .externalNativeBuild directory from my project. After manually deleting them the process build correctly with no errors.
go to files and click invalidate cache/restart
Related
Getting an error when trying to fix error -
No toolchains found in the NDK toolchains folder for ABI with prefix mips64el-linux-android
Do not want to upgrade as afraid it might break my application and need to use NDK to work with C++.
After following steps for workaround to fix the error -
Error: No toolchains found in the NDK toolchains folder for ABI with prefix: llvm
New error:
Expected caller to ensure valid ABI: MIPS
Any help on how to fix the issue.
You should specify an ABI filter.
You haven't mentioned how you are building. If you're using Gradle, then you put something like this in the defaultConfig block in your build.gradle:
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
If you're invoking ndk-build directly, then you put this on the ndk-build command line:
APP_ABI=armeabi-v7a arm64-v8a x86 x86_64
Or inside your Application.mk:
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
The ABI filter I showed is just an example. It's up to you to decide which ones you want to build for. arm64-v8a and armeabi-v7a are by far the most common ones among Android devices.mips, mips64 and armeabi are no longer supported by the NDK.
From your TOP-LEVEL build.gradle, change your classpath for android gradle plugin to 3.2.1 or higher.
classpath 'com.android.tools.build:gradle:3.2.1'
Or for other options, please check here: Three options for solving this kind of issue
Using Application.mk, it looks like the ABI targets can be selected with the option APP_ABI:
APP_ABI := armeabi-v7a,arm64-v8a,x86,x86_64,mips
I can't seem to find any such options for CMake builds. The file CMakeLists.txt seems to be called with the ANDROID_ABI option passed in, but I can't find any corresponding configuration options in the gradle plugin.
You should use abiFilters:
android {
defaultConfig {
ndk {
abiFilters "x86"
}
}
}
I have an Android Library project which has a part in C/C++ via Android NDK. I want to build my native code for all architectures. If i set minSdkVersionto 21 it all works fine. but i need to have lower minSdkVersion(SDK 19) if i set minSdkVersion to 19 the ARM64-v8a version is not built. I know that there are no ARM64-v8a devices running SDK 19. How can i achieve to have all platforms built in one APK and have minSdkVersion 19?
Actually, there is typo in "minimumSdkVersion". The right attribute is "minSdkVersion".
However, arm64-v8a library should be successfully built for API 19, because NDK build scripts will automatically take right set of platform headers and libraries.
If you are using Gradle build scripts try to set it as one of target ABIs:
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
Then, explicitly set target platform for native build. If you use CMake, then in gradle script set:
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-19'
}
}
If you use ndk-build, then in your Application.mk set:
APP_PLATFORM := android-19
I hope that helps. Please, write details if it will not build.
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.
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
Android Studio 2.2 Preview 1 has a new external ndk build feature, but from app/build.gradle snippet shown in official blog post it's not clear at all how to set additional ndk build parameters which Application.mk file usually contains
I'm able to set Android.mk ndk build file via externalNativeBuild, but how could I set the required Application.mk variables?
My Application.mk contains:
NDK_TOOLCHAIN_VERSION := clang
APP_PLATFORM := android-16
APP_ABI := armeabi
APP_STL := c++_static
APP_CPPFLAGS += -std=c++11
Android Studio 2.2 Preview 3 with updated gradle plugin added support for additional arguments. You can set Application.mk and additional configuration like this:
defaultConfig {
ndkBuild {
arguments "NDK_APPLICATION_MK:=Application.mk"
cFlags "-DTEST_C_FLAG1" "-DTEST_C_FLAG2"
cppFlags "-DTEST_CPP_FLAG2" "-DTEST_CPP_FLAG2"
abiFilters "armeabi-v7a", "armeabi"
}
}
If possible I would recommend migrating to CMake build system, because of better C++ code editor and debugging integration in Android Studio. You will find more info on gradle plugin configuration here:
https://sites.google.com/a/android.com/tools/tech-docs/external-c-builds.
Edit:
From Android Studio 2.2 Preview 5 you must wrap cmake and ndkBuild groups under externalNativeBuild group:
defaultConfig {
externalNativeBuild {
ndkBuild {
targets "target1", "target2"
arguments "NDK_APPLICATION_MK:=Application.mk"
cFlags "-DTEST_C_FLAG1", "-DTEST_C_FLAG2"
cppFlags "-DTEST_CPP_FLAG2", "-DTEST_CPP_FLAG2"
abiFilters "armeabi-v7a", "armeabi"
}
}
}
Edit 2: It seems that wrapping ndkBuild under externalNativeBuild group does not work because of a bug in build tools.
add-native-code
android {
...
defaultConfig {...}
buildTypes {...}
// Encapsulates your external native build configurations.
externalNativeBuild {
// Encapsulates your CMake build configurations.
cmake {
// Provides a relative path to your CMake build script.
path "CMakeLists.txt"
}
}
}
Note: If you want to link Gradle to an existing ndk-build project, use the ndkBuild {} block instead of cmake {}, and provide a relative path to your Android.mk file. Gradle also includes the Application.mk file if it is located in the same directory as your Android.mk file.