Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write applications on android using only C?

Tags:

android

Now wait just one moment before you mark this as a duplicate, because this is a very specific question.

I'm not asking if you can write an application using another language which is a binding using the NDK; what I want to know is:

  1. At a hardware level, how does dalvik interact with the Linux kernel on android devices?

The answer to (1) as I understand it, is that because android is fundamentally a Linux system, this is done via syscalls. Which is to say, at some level the davlik/art VM must interact with the C Linux kernel through a C API.

  1. If you had root permission on a device, why could you not do the same thing from a native system binary?

So, certainly it would be a painful experience, but technically is there any reason why it would not be possible to write an application purely in C, without using the android run-time at all?

(Note: Not without the run-time; obviously the run-time must be present to do various things like device initialization; but a stand alone binary that did not interact with the run-time).

(I can think of a few reasons why this might be the case, specifically the run-time requiring exclusive hardware access to various hardware, but I can't find any specific documentation about it)

like image 518
Doug Avatar asked Nov 10 '22 03:11

Doug


1 Answers

It is possible, this is how daemons work on Android (think RILD for example). However you cannot gain access to the Android facilities (graphics, location, etc) as there is no API from C.

Note that in order to speak to the Android API, your process needs to be a child of zygote. If you spawn a process from an ADB shell, or from init you will not be a fork() of zygote and will not have direct access to the JVM.

like image 84
elcuco Avatar answered Nov 15 '22 07:11

elcuco