我尝试着将一款游戏移植到Android上,但它是基于C语言,而Android也支持Java,但我相信一定有一种方法能够将C应用带到Android上,有人知道如何实现这一目标吗?


当前回答

谷歌已经在http://www.youtube.com/watch?v=5yorhsSPFG4上发布了谷歌I/O 2011:将C和c++游戏引入Android会议

这有助于理解NDK在c和c++中编写应用程序的使用。

如果你只是想交叉编译任何基于主机的原生游戏,并在android上运行它们,那么本文将展示3种方法。

1:使用独立工具链的静态编译

2:使用Android NDK的工具链进行交叉编译

3:交叉编译使用AOSP源代码

其他回答

谷歌刚刚发布了NDK。

http://feedproxy.google.com/~r/blogspot/hsDu/~3/2foWz7hwFtE/introducing-android-15-ndk-release-1.html

可以在这里找到: http://developer.android.com/sdk/ndk/1.5_r1/index.html

您可以使用nestedvm将C(或其他GCC语言)转换为Java字节码,并将其用作您的端口的基础。例如,《Simon Tathams》的Android移植版本。

我预计这种方法已经被NDK淘汰了,但如果一些网络或其他东西不允许人们升级他们的手机,它可能不会被淘汰。

简单的回答:你不能。

@Backslash17:看了这篇文章和下面的安装说明链接,该公司所做的只是在模拟器上启动一个自编译的可执行文件,绕过了android框架。一旦你有了模拟器,你就可以远程登录并拥有一个linux shell。在那里运行一个linux程序当然很简单。 但这对于没有越狱(也就是根权限)和市场上无法交付的手机来说是行不通的。

除非谷歌打开了其他机会,或者有人编写了一个自定义编译器,将Language X编译成Dalvik字节码(Dalvik是运行Android程序的虚拟机),否则您将无法编写本机代码。

从这一点来看,似乎是有可能的:

http://openhandsetmagazine.com/2007/11/running-c-native-applications-on-android-the-final-point/(现在只能通过WayBack Machine购买)

"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."

这篇博客文章可能是一个好的开始:http://benno.id.au/blog/2007/11/13/android-native-apps 不幸的是,很多重要的东西都“留给读者做练习”。