Android ndk ncurses - android-ndk

I'm trying to compile ncurses for android and build the ncurses static library. However I cannot understand how to go about.Anyone with any idea how to go about it using ndk-build?

Related

which cmake will Android plugin use?

With Android Studio 3.3 I use native (C++) library, which I built with CMake. The Android plugin (v. 3.2.1) will choose the 'builtin' or 'external' cmake, depending on the configuration of externalNativeBuild, as documented at developer.android.com.
I want to add an extra custom task (install) that should use the same cmake version as the Android Plugin. But even with the 'builtin' cmake, it's not clear what the path is. I can find android.sdkDirectory, but even there I have today sdk\cmake\3.6.4111459 and sdk\cmake\3.10.2.4988404, and for some strange reason, some of my projects choose 3.6, while others use 3.10. This contradicts the official the release notes for Android Studio that "Gradle still uses version 3.6.0 by default", but well…
How can I decide which to use, without reimplementing the Android Plugin's obscure logic?
One workaround that may help, parse the first line of the generated file .externalNativeBuild/cmake/debug/armeabi-v7a/cmake_build_command.txt:
Executable : C:\local\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe
This still needs some adjustments, because the later versions of build tools will use .cxx instead of .externalNativeBuild; the build variant names may be different too.
Android Studio will pick up the latest CMake version under sdk\cmake, but you can configure your particular version from
externalNativeBuild {
cmake {
...
version "cmake-version"
}
}
And specify our custom CMake director as below inside local.properties
cmake.dir="path-to-cmake"
Or, you can choose NOT to upgrade your CMake from SDK Manager (just to delete the sdk\cmake\<version to delete> folder will be fine) so that you can stick to the CMake version your project is comfortable with.

Generating protobuf c++ code inside Android Studio

I am trying to build a bridge between Java and C++ using Protobuf for serialization and storage purpose, inside an Android Studio project. Things work well on the Java side. Using the JavaLite plugin, I am able to generate the classes for each file.
Where things start to break is trying to do the same on the native side. I've tried many things and I came to the conclusion that using cmake would be the best way to get there. However, I am running into some issues.
Cmake doesn't seem to know about protobuf. When I add these lines to CMakeList.txt:
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
I am getting:
-- Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
which is strange since my version passes the smoke test:
cmake_minimum_required(VERSION 3.4.1)
Sanity check, from terminal:
$ protoc --version
libprotoc 3.5.1
What are the other option to generate C++ protobuf in Android Studio? Would NDK-build be another option?

Android NDK - building native libraries without Android Studio

I'm working on a c/c++ cross-platform project, constructed of 2 main libraries (with a few external dependencies: ssl, yajl, fribidi).
The android solution will include Java files and a JNI layer, all bundled in a AAR file (including assets and the native libs).
I managed to build the whole project, but in a very awkward way:
I created a 'hello world' Android app', with native support, from within Android Studio, and added all native dependencies to the CMAkeList.txt. I added my Java code + JNI and managed to create the AAR (only for ARM, for now).
Now I need to separate the build of the different libraries, to their separate projects, respectively: libA, libB and C.aar.
How is it done without the IDE (and via command-line)?
There's the stand-alone NDK, the make_standalone_toolchain.py script, android.toolchain.cmake and other options, but none are documented or up-to-date. Most documentation still talks about the outdated Android.mk methodology.
I'd presume including android.toolchain.cmake in my CMakeList.txt, which will set all needed environment...
I'm using the newest Android Studio 3.0.1 and NDK r16b (installed via SDK Manager)
Alex - thanks, exactly what I was looking for. Just had to add a few flags and a call to make:
> cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-19 -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK%\prebuilt\windows-x86_64\bin\make.exe -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" ..
> cmake --build .
Android Studio (the standard Android gradle plugin, that is) does not support native-only modules, but you can split your CMake script and work with libA and libB separately. You can run cmake from command line (but better use the version that is shipped with Android SDK).
sdk/cmake/3.6.4111459/bin/cmake -DCMAKE_TOOLCHAIN_FILE=sdk/ndk-bundle/build/cmake/android.toolchain.cmake ...
The easiest way to build the AAR file that includes a compiled Java wrapper and the two native libraries would be with Android Studio, but you can run the gradle task from command line. This is what we typically do on a build server.

Build Glibc for android ndk in eclipse

I have a C program (which uses glibc) that I wish to run on android. I installed android ndk and have setup the basic things. How should I link glibc library to my android project in eclipse?
Thanks
How should I link glibc library to my android project in eclipse?
Android doesn't use GLIBC (it uses Bionic instead).
So your first step would be "port GLIBC to work on Android". Your question suggests that you may not be up to that task, and a better approach may be to make your program compatible with Bionic (i.e. to not use any glibc-specific extensions) instead.

Chrome packaged app and Android NDK

Is it possible to have a Chrome packaged app for Android also include a module built with the Android NDK, and then communicate between the app's javascript and the native NDK module?
Because PNaCl is not yet available for Android, I'm looking for another way to bring C code to that platform also, in place of the PNaCl module that I have for the other platforms.
You can install cordova plugins using the cca tool, and cordova plugins can bundle ndk components. However, there is no utility/project that I know of to help you get started build ing the android ndk -> cordova android -> cordova js.
I don't think it should be hard, especially if you've done cordova/phonegap plugin development before.

Resources