Write applications in C or C++ for Android? [close

2020-01-25 03:24发布

I'm trying to develop/port a game to Android, but it's in C, and Android supports Java, but I'm sure there must be a way to get a C app on there, anyone knows of a way to accomplish this?

标签: c++ c android
20条回答
老娘就宠你
4楼-- · 2020-01-25 03:40

Short answer: You can't.

@Backslash17: Looking through the article and the following link with installation instructions, all the company got working is to launch a self compiled executable on the emulator, bypassing the android framework. Once you have the emulator you can telnet in and have a linux shell. Running a linux program there is trivial of course. But that's not working for phones without jailbreak(aka root access) and not deliverable on the market.

Unless Google opens other opportunities or someone writes a custom compiler that compiles Language X into Dalvik bytecode (Dalvik is the VM that runs Android programs) you won't be able to write native code.

查看更多
你好瞎i
5楼-- · 2020-01-25 03:43

You can use nestedvm to translate C (or other GCC languages) into Java bytecode, and use that as the basis of your port. For example, see the Android port of Simon Tathams portable puzzle collection.

I expect this method is made obsolete by the NDK, but it might not be in if some networks or something don't allow people to upgrade their phones.

查看更多
Summer. ? 凉城
6楼-- · 2020-01-25 03:44

Looking at this it seems it is possible:

"the fact is only Java language is supported doesn’t mean that you cannot develop applications in other languages. This have been proved by many developers, hackers and experts in application development for mobile. The guys at Elements Interactive B.V., the company behind Edgelib library, succeeded to run native C++ applications on the Android platform, even that at this time there is still many issues on display and sound … etc. This include the S-Tris2 game and a 3D animation demo of Edgelib."

查看更多
We Are One
7楼-- · 2020-01-25 03:44

I'm not sure the NDK provides full coverage of the official Java API.

From http://developer.android.com/sdk/ndk/index.html#overview :

Please note that the NDK does not enable you to develop native-only applications. Android's primary runtime remains the Dalvik virtual machine.

查看更多
登录 后发表回答