This is a distribution of the CrystaX NDK, which has been developed as a drop-in replacement for Google's Android NDK (Native Development Kit). Compared to Google's NDK, the CrystaX NDK provides the same functionality as well as several great features and tons of fixes and improvements.
The main goal of the CrystaX NDK is to allow Android developers to produce standard conformant code and thus make Android native development more efficient. The CrystaX NDK dramatically decreases development time allowing usage of standard code working on multiple platforms (iOS, OS X, Windows, Linux, etc.) instead of distracting developers with Android's peculiarities and forcing coders to try to workaround them (or even write separate Android-specific implementations of functionality already implemented for another platform if a detected problem cannot be easily worked around).
Unfortunately, Android libc (Bionic) has very limited functionality (which differs from one Android version to another), so developers have been forced to take into account all its peculiarities, detecting in run-time which specific Android version the application is running on and applying specific workarounds. With CrystaX NDK, developers can forget about such problems, since CrystaX NDK provides complementary libcrystax, which is used to hide such differences between Android versions or even re-implement many of libc functions. Most importantly, with the help of libcrystax, the application behaves the same on all Android devices regardless of Android version.
Another goal of CrystaX NDK is to make some great features available for the Android native world. For example, support of Objective-C and another programming languages.
This project was initially started as a personal project of Dmitry Moskalchuk with the intention to just add missing C++ support (C++ exceptions, RTTI, and the Standard C++ Library) to the Google's Android NDK, but with time, many additional needs were discovered, and it turned out that improving the CrystaX NDK step-by-step was in fact the best way to force an evolution of native Android development. Since its beginning in 2009, numerous open-source and commercial projects have used the CrystaX NDK for porting and development for Android with minimal effort.
Nowadays, CrystaX NDK offers numerous great features, making native development for Android easier. See below the key features of the CrystaX NDK.
- Full support of wide characters
Wide characters are part of C and C++ languages and their standard libraries. For example, the C standard library provides functions allowing work with wide strings such as wcsnlen, wcsncasecmp, wcsncmp and others; the C++ standard library provides wchar_t specializations of standard C++ classes such as std::basic_string, std::basic_ostream, std::basic_regex etc. Unfortunately, Android libc (Bionic) either doesn't support wide characters at all or supports them in a very limited manner, depending on Android version.
With the CrystaX NDK, you get fully standard-compliant wide characters support, including multibyte-to-wide and vice versa conversions. You can easily port existing code or write new code that uses wide characters, strings, streams, and regular expressions not distracting on Android's peculiarities.
- Full support of C locales
Android libc (Bionic) has no native support of locales, so the only way to use localized input/output in native code is to implement localization in Java and refer to it through JNI. Obviously, such an approach adds significant run-time overhead, but it's the only choice if you're using Google's Android NDK.
Now, with CrystaX NDK, locales are supported natively, so just set a locale with standard setlocale and all further C standard function calls will use that locale for input and output. CrystaX NDK also supports so-called "extended locales" (part of IEEE Std 1003.1, 2013 Edition), providing companion locale-enabled functions for many standard C interfaces, such as printf_l, strftime_l, strfmon_l and others.
- Full math support, including complex and type-generic math functions
ISO C standard defines headers <tgmath.h> and <complex.h>. In Google's Android NDK, <complex.h> appears only starting from r10 and only for applications targeting Android 5.0 (android-21 platform), whereas type-generic math functions are not supported at all.
With CrystaX NDK, you get fully working complex and type-generic math regardless of the target Android version. Nothing more to say - just use it as defined in ISO C standard and enjoy!
- The most recent toolchains
The CrystaX NDK includes the most recent versions of GCC and Clang compilers. This allows developers to use new language abilities, such as new C++11/C++14 features. All compilers are built with high- and low-level optimizations, which enable generation of the most efficient code for target hardware.
- C++11/C++14 support
- Full C++ standard library
In addition, the CrystaX NDK offers a fully working C++11 standard library, including classes std::thread and std::mutex, functions/classes from std::chrono, and functions std::stol, std::stoul etc. These classes and functions are not available (or available with restrictions) in the Google's Android NDK because of a lack of functionality in Android libc (Bionic).
In the CrystaX NDK, we've taken care of the completeness of the C++ standard library and have fixed all such issues, so the full C++ standard library is available no matter which implementation you're using - GNU libstdc++ or LLVM libc++.
By the way, LLVM libc++ in CrystaX NDK is a first-class citizen, the same as GNU libstdc++, so you're free to use either one of them, your choice. By default, GNU libstdc++ is used.
- Boost C++ libraries out of the box
We provide prebuilt Boost C++ libraries (as well as header-only libraries) out of the box. Boost usage become as simple as can be. No need to build Boost libraries on your own anymore; no need to figure out what's wrong when it fails. Most important, Boost C++ libraries works much better with CrystaX NDK than the same libraries built by Google's NDK - because in CrystaX NDK they works on top of the much more standard-conformant base (yes, it's libcrystax, core of the CrystaX NDK).
Here you can see an example of how to start using Boost C++ libraries in your Android project.
- Objective-C and Objective-C++ support
The only languages Google's NDK supports are C and C++. CrystaX NDK adds support of Objective-C and Objective-C++ in addition to C and C++.
Starting from CrystaX NDK 10.2.0, we've added support of Objective-C v2 runtime and initial frameworks (Foundation and CoreFoundation).
Here you can see a simple example of how to use Objective-C for Android development. In two words, just add source files with the extension .m (Objective-C) or .mm (Objective-C++), specify them in LOCAL_SRC_FILES in Android.mk and add "APP_OBJC := cocotron" in Application.mk.
- Tons of fixes and improvements of standard C library implementation
It's a well-known fact that Android libc (Bionic) has many bugs in its implementation of standard C functions. For example, one of the most notorious bugs is strtod implementation, which works properly only for the simplest input string formats and fails for others required by ISO C Standard. Some of these bugs are fixed over time, others aren't. Anyway, even if some bugs are fixed, such fixes don't affect previously released Android versions, so developers are forced to live with them or implement their own workarounds. This significantly increases time for development or porting of native Android applications.
In CrystaX NDK, we've implemented our own versions of such buggy functions in libcrystax and have done so without altering the typical development work flow. Compilers/linkers use libcrystax transparently for developers so one won't even know that a libcrystax implementation is being used instead of a Bionic (except for the fact that the behaviour has been fixed). Also, using CrystaX NDK, you'll never run into a situation where a bug fix is available only for specific Android versions. When we fix anything in libcrystax, we ensure it works on all Android versions.
- To be continued...
The content of the CrystaX NDK is covered by various open-source licenses. See the copyright disclaimers in each respective file for details.
Note that the CrystaX NDK release packages also contain prebuilt binaries for the compiler, linker, archiver, etc. The source codes for the toolchains are available at GitHub (you can use the build script to download it automatically).
The prebuilt GCC and companion binaries (GDB, binutils etc) are covered by either the GNU General Public License (GPL) or the GNU Lesser General Public License (LGPL). For details, see the files COPYING and COPYING.LIB under $NDK/toolchains/$tc/prebuilt/$system.
The prebuilt LLVM/Clang toolchains are covered by the LLVM "BSD" license.
Basically, licensing rules are the same as for Google's Android NDK - i.e., both commercial and non-commercial usage allowed. The only additions are regarding CrystaX parts, which are covered by a permissive BSD 2-clause license.
We're working hard on making CrystaX NDK as good as possible. However, there is no guarantee it's bug-free - as everything in this world. So if you find a bug, please report it to us and we'll do our best to fix it.
Also, you can use the public discussion group to ask about CrystaX NDK (for example, if you're unsure if something is a bug or feature). You can post a question via the web interface or use it as a good old mailing list: send e-mail to email@example.com. This is a pre-moderated group, so don't worry if you don't see your post immediately; give us some time to see and approve it.
Finally, you can directly contact us if the above options don't fit your needs.
How to build
You can also build the distribution from sources if you don't want to use the prebuilt versions for some reason. Follow the instructions below.
Setting up the build environment:
Follow the instructions from the AOSP site (except the Java part):
WARNING!!! Building the Windows version of CrystaX NDK is only supported on a Linux host (cross-build used). Building on a Windows host is not tested and not supported.
Download the build script and run it.
\curl -sSL http://crystax.net/download/ndk-crystax-r10-build.sh | /bin/bashIt will take a long time - up to many hours. When the script is finished, it will print the directory containing the package with the NDK release.
- You're done! Use this package as a drop-in replacement for Google's NDK!
Thank you for downloading CrystaX NDK!
CrystaX NDK is a fully open source project, free to use in any open-source and commercial environment. We provide it free for use and don't ask our users to pay in exchange. However, we appreciate your support, through sending us pull requests, spreading the news about CrystaX NDK over the world, or just donating:
Who we are
We're a small team of developers who want to make development for Android easier. Our goal is to create a comprehensive toolkit for native development for Android on C, C++, Objective-C, and, potentially, in other programming languages already working on modern POSIX systems (Swift, D, Haskell, Ocaml, Python, Ruby - you name it).
We've already done a lot (as you can see on our main project page), but we want to do even more. We have a long way to go, but we know how to do it and can clearly see the steps required to make it happen. You can read more about us here.
Why we need your support
Since we started working on CrystaX NDK, we have funded ourselves without any sponsorship. That has led us to make money in other ways (such as working as contractors and doing consulting jobs on other projects) and invest our earnings in the CrystaX NDK project. Because of this we have only been able to work on NDK part-time, which means it is not as powerful as it could be.
Having support from the community, we could pay more attention to CrystaX NDK development, without the distraction on paid contracts. This will speed up CrystaX NDK development as well as bug fixing and support.
Optionally, sponsors (those who send us $200/month or more) get in exchange a number of perks - they get priority for consulting or training needs, they can be listed on the front page of the CrystaX website and mentioned in the project README, etc. Please read here for more details about sponsoring options.
When the download is finished, please check that the downloaded file is not corrupted!
The SHA-256 hash must be .
Here is an example of how to check it using OpenSSL:
$ CHECKSUM= && \ FILE= && \ diff <(openssl sha256 $FILE) <(echo "SHA256($FILE)= $CHECKSUM") \ && echo 'OK' || echo '*** CORRUPTED!!!'