Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What is like working with the NDK? C++ is the one language that can work on both iOS and Android (and Windows phone?)

Personally, I'd like to get some reuse out of my iOS code. I'd do more C++ if I knew that I could reuse it. Of course, Objective C could actually be portable too.



I find the NDK fine to work with - but I'm writing a game which is entirely C plus some embedded Lua/Moonscript.

I develop on Linux (Ubuntu), with a make file set up to build for desktop or for Android with one command, and it just works. Took a little bit of time (maybe an hour) to get the build scripts set up for Android initially, but after that it's been great.

As I'm writing a game I'm using entirely custom UI etc. so I don't worry about not being able to access the normal Android UI classes and such. I do a little bit of JNI for loading resources but that was trivial to write. My game engine works exceedingly well cross platform for desktop X86 and Android/ARM.

My email is in my profile if you have any questions.


> C++ is the one language that can work on both iOS and Android (and Windows phone?)

C# can do that too, using Xamarin.


C++'s benefit is that it is common to all SDKs.

With Xamarin you must buy it, which may not be an option for hobby developers.


Xamarin does have a nice UI for working with Xcode/iOS, though I too fall on the cheap side of the fence. :)


I have played around with all three, Java, C++, C#.

For business I would surely advise Xamarin, as their prices are quite reasonable.

But if you are just hacking some stuff every now and then, it might not be worth it.

And on that case, there is also the possibility to compile Java to native code in iOS (RoboVM) or use any other language that either has an AOT compiler, or has a compiler available that compiles via C.

It is always a matter how much time vs money, one wants to invest.


Pretty horrible. The gdb debugger is a pain in the ass to setup, there is no really good ndk based IDE, most of the UI and important API classes either aren't available or are vastly more complex to use, You still have to use java- if for nothing else to load and start the c/c++ code running, and JNI is a absolute pig of a technology for interfaces with other code. As a mobile dev working on iOS, Android, and Win Phone who occasionally needs the native performance of c I really wish it was better.


Having worked with the NDK in Android Developer Tools (Google's Eclipse Fork), it's pretty painful. It takes a long time to get the environment set up and working (somewhat) nicely. You have to get a plugin to debug via ADT, I used the ARM DS-5 debugger. It works, but it's not a good user experience.

I used to complain about certain niggles in Xcode, but having used ADT, I shall never complain again. Comparatively, using Xcode is a joy.


I used the Android NDK extensively for an app I wrote recently. The main reasons were for cross compatibility (future iOS port) and because a 3rd party library I needed was written in C.

If your new to the world of C/C++..then maybe its painful, but for me it was easy to get up and running. They use the GCC toolchain behind the scenes, with gdb as the debugger.

The NDK exists as a download for windows,OSX and Linux. I developed exclusively on OSX (10.8) (Using the android develop toolkit (aka ADT) which is basically a re-skinned Eclipse) and then enabled "ADB over IP" on my Nexus 4.

After a bit of setup (like adb connect 'local ip' ) the Android version of gdb (ndk-gdb) on the mac just "sees" your phone, finds the process and automatically connects.

If / when a crash would happen (and it happend a lot :) ) you get a stack trace, code line numbers, etc.

It might not be as simple as the GUI Xcode world, but it certainly works.

I've also got remote core dumps for my app, using Google's Breakpad. When the app crashes natively it uploads a core dump to my server, where I can examine what happened. Here as well you get full stack dumps, line #'s, etc.


As far as a cross-toolchain goes, the NDK is quite nice. For the most part, it Just Works for compiling code. The multitude of STLs and complicated (behind the scenes) Makefile system can be annoying. However, the Makefile system is very simple for common needs. Debugging can be a pain, yes. Google is very diligent about releasing updates to fix bugs.

It also has Clang now!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: