Expected caller to ensure valid ABI: MIPS - android

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

Related

Android NDK: How to build for ARM64-v8a with minimumSdkVersion = 19

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.

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.
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

How to set up Eclipse's Build Configurations to produce a proper, debuggable NDK app?

We have an Android NDK project that has three different build configurations:
DEBUG - armeabi
DEBUG - armeabi-v7a
RELEASE - aremabi + armeabi-v7a
We specify separate aremabi and armeabi-v7 debug configurations due to a known bug in the Android loader, where if more than one EABI is specified, the debugger may launch the wrong EABI version of the App and no native breakpoints will ever hit (More details here, at the end of the document).
On the past, we edited the Application.mk file and specified the desired EABI by means of the APP_ABI variable.
We would like to avoid this manual editing and take advantage of Eclipse's Build Configurations and choose the proper EABI setting automatically.
So far, we have a working solution by adding conditionals to the Application.mk file
Here is how our Application.mk looks:
ifeq ($(BUILD_CONFIG),RELEASE)
APP_OPTIM := release
APP_ABI := armeabi armeabi-v7a
else ifeq ($(BUILD_CONFIG),ARMEABIV7A_DEBUG)
APP_OPTIM := debug
APP_ABI := armeabi-v7a
else ifeq ($(BUILD_CONFIG),ARMEABI_DEBUG)
APP_OPTIM := debug
APP_ABI := armeabi
endif
Additionally, we customised the compiler build command line in Eclipse so that the proper BUILD_CONFIG variable is passed to the make script.
This works very well for compilation purposes, but the problem begins when we try to debug the application. The thing is that we don't know how to pass the BUILD_CONFIG variable to the ndk-gdb script.
Running the ndk-build DUMP_APP_ABI command will always return ARMEABI (expected since we are not explicitly defining the BUILD_CONFIG parameter), and as far as I understand, this is the value that ndk-gdb is reading in order to decide which version of the application will be launched by the debugger.
Has anyone managed to get this working or have an alternative solution where we can get compilation and debugging working properly with Eclipse's Build Configurations? Running a command that patches or renames the Application.mk file is a possibility, but we don't know how to do that either.
Android 4.0 has bug. If you provide armeabi and armeabi-v7a code then armeabi code is loaded even if you have ARMv7 compatible CPU. Android 4.0 ignores armeabi-v7a when armeabi is available.
That is why you can create 2 versions of your lib targeted to armeabi (ARMv5)
But there is no ARMv5 CPUs (HTC Hero)
So most CPUs are ARMv6 or ARMv7
You should detect your CPU in Java and load proper native lib.
Doing these will give you control what .so loaded exactly.
You would be able to create lib with NEON support.

Compiling Android applications for Cotex A 8

I have successfully installed Android Gingerbread 2.3.4 on Beagleboard XM, which is having Cortex A-8. How do I select Cortex -A-8 as target in Eclipse for cross compiling?
Thanks and regards,
Heshsham
You specify which ABIs to support in an ndk project by putting a line in your Application.mk file. If that portion of your source tree is in Eclipse's view of the project you should be able to edit the file from eclipse, otherwise you can use your favorite editor.
http://developer.android.com/sdk/ndk/index.html gives an example of how to include mips support:
APP_ABI := armeabi armeabi-v7a mips
For Cortex A-8 you'd basically just need to figure out the appropriate ABI name.

How to create fat static library for an Android application on MacOS?

I'm trying to build static FAT library for Android NDK which should contain armv6 and armv7 versions.
Tried libtool - doesn't help, cause on MacOS it is not compatible with Android ABI.
Tried ranlib that I found in my NDK folder also with no success.
As an option could someone explain how should I use Android.mk to specify an appropriate library for an architecture.
On Android you don't (at least currently) create fat binaries. Instead, your APK will contain 1:n binaries for the architectures you wish to support.
Your Application.mk (preferred) or Android.mk should define a APP_ABI variable for the architecture(s)
For example, to support ARM (generic) and ARMv7a:
APP_ABI := armeabi armeabi-v7a
See $(NDK)/docs/APPLICATION-MK.txt for more information.

Categories

Resources