Developing native C applications android without the NDK?
Asked Answered
C

4

9

OK this is a strange one:

Is there a way someone can develop native C applications or libraries for Android without using the Android NDK?

What was happening before the NDK was released? (It's not there for too long, I think it was released only one or two years ago).

Croquette answered 30/7, 2012 at 9:38 Comment(1)
Root the phone, compile for LinuxUniliteral
A
5

Before the NDK was released, the only officially supported way of developing Android applications was to use the Android SDK and writing your applications in Java.

As others have mentioned, it's possible to cross-compile some applications as completely stand-alone and run them on a rooted phone. The downsides of this should be obvious: very few people will be able to run your application (they also need to be root, plus you won't be able to get your application up on the Play store); and you might even run into compatibility problems yourself across different devices e.g. if you rely on dynamic linking against various libraries (which you might need to do in order to keep the size of the binary down).

TL;DR: it's possible, but severly limited, and not recommended.

Albano answered 30/7, 2012 at 10:3 Comment(0)
C
5

Apparently, you can -- a friend of mine is a real Android guru and he managed to build a GCC-based native toolchain entirely by hand. He also fixed some missing parts in Android's libc. The main idea is the following: GCC has builtin support for the arm-elf-linux target, so with an appropriate build script, you can configure it to build for Android. However, you have to root the phone to run the resulting binaries. One even cooler thing is that because GCC is a self-hosting compiler, with the arm-linux-elf toolchain, you can recompile GCC once again and have the toolchain on the phone itself.

Chainey answered 30/7, 2012 at 9:42 Comment(0)
A
5

Before the NDK was released, the only officially supported way of developing Android applications was to use the Android SDK and writing your applications in Java.

As others have mentioned, it's possible to cross-compile some applications as completely stand-alone and run them on a rooted phone. The downsides of this should be obvious: very few people will be able to run your application (they also need to be root, plus you won't be able to get your application up on the Play store); and you might even run into compatibility problems yourself across different devices e.g. if you rely on dynamic linking against various libraries (which you might need to do in order to keep the size of the binary down).

TL;DR: it's possible, but severly limited, and not recommended.

Albano answered 30/7, 2012 at 10:3 Comment(0)
T
3

You can compile your C code with an Android-compatible toolchain (such as CodeSourcery) and run it on a non-rooted phone, from its command line (for example through an SSH connection like SSHDroid).

Twyla answered 31/8, 2012 at 11:30 Comment(0)
S
0

Yes, you can.

c4droid can compile c code directly into apk file in your android phone without ndk or android studio.

Here is a link to c4droid: https://www.mediafire.com/file/wnt7txwz5296ajs/c4droid_can_compile_c_into_apk_in_android.tar.gz/file

Shiah answered 20/2 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.