Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the NDK required for good performance in the development of an Android Game?

I heard if I develop Android Game without using the NDK, the performance is significantly lower. Is this the truth?

like image 607
user1788012 Avatar asked Mar 15 '13 07:03

user1788012


2 Answers

I see 3 main reasons to use NDK:

  • you want to reuse C/C++ code base (e.g. game engine written in C++, crossplatform games)
  • get more memory (you can use much more memory via NDK)
  • your game is very CPU intensive and you need all your device power.

In all other cases you can choose whatever you like. SDK/Java allows you to use OpenGL same way as NDK, so your graphics won't slow. You should be careful with GC to get smooth gameplay. If your game is very CPU intensive you can write some methods in C++ and call them via JNI. By the way, Dalvik has JIT so Java code can be as fast (even faster sometimes) as C code.

like image 53
Leonidos Avatar answered Nov 15 '22 05:11

Leonidos


No, that is simply not true.

It very much depends on what your particular game is doing. The essential question is: is your game going to be CPU intensive (or require larger amounts of memory).

  • If it's not, stick to the SDK.
  • If you don't know, because you haven't written many games yet in the past, by all means stick to the SDK.
  • Even it there turn out to be parts of the game that could do with the extra processing power, you can always extract those parts to native code during development as needed.

One reason to choose the NDK over the SDK is having a huge background in C++, which might make you more productive in that environment. However, given the current state of the toolsets (convenient debugging, build times, easy access to SDK libraries etc), this is rarely effective.

like image 39
Paul-Jan Avatar answered Nov 15 '22 05:11

Paul-Jan