Posts

Showing posts from 2012

How to use Makefile wildcards/globbing on Android NDK JNI

Here is a short little thing I ran into a few days ago.  Many of you may know how a normal Android Makefile looks, something like this: LOCAL_PATH := $( call  my-dir) MY_PATH := $(LOCAL_PATH) TARGET_ABI       := android-4-armeabi include   $(CLEAR_VARS) LOCAL_MODULE     := libmain LOCAL_C_INCLUDES := \    $(LOCAL_PATH) /Box2D \    $(LOCAL_PATH) /libpng \    $(LOCAL_PATH) /libzip \ LOCAL_CFLAGS := \    -g3 \    -ggdb \    -gstabs+ \    -DANDROID_NDK \ # Look here! LOCAL_SRC_FILES := \   main.cpp    \   cool_file.cpp    \    LOCAL_LDLIBS := -lGLESv1_CM -llog -lz LOCAL_STATIC_LIBRARIES := libBox2D libzip libpng include   $(BUILD_SHARED_LIBRARY) Ok, notice the section  LOCAL_SRC_FILES  .  If you have many files in your project this could grow huge.  O(N) where N is...

Development on Android NDK Tutorial - Gluing C++ Native Code to Java

Image
Too busy to draw this time.. for now here's a picture of an Android Toy Ok, in this post I am going to talk about how to join C++ native code to a thin Android Java code layer.  I am not going to be doing all native code, as I think the easiest route is to use the Android higher level convenience SDK for loading resources/file I/O, setting up OpenGL context and other state management. I won't be using any IDEs or anything else to complicate things.  This is as easy as it can get, you get the source and type "make" (I assume you are on a system with GNU make, and your environment is setup correctly.  Linux is easiest, but it should run fine on ANY system that can run Make, even Windows!). So the code will be structured like this: -----------------------------------  Android SDK OS Layer code -----------------------------------   Java App Thin Layer to Android OS -----------------------------------   Native C++ code called by...

Development on Android NDK using VIM and CGDB

Image
Android representing Vim Using Vim to program Native Android code (NDK). You've likely found this page since you're like me, a vim editor advocate that loves the productive features of vim and are getting into Android programming, but maybe you aren't quite sure how to get started.  I don't really find much benefit in using IDE's for C/C++ game development since many times I am making custom make targets to create assets or other such customization that are painful or not possible in IDEs.  Also, let's face it, vim and emacs (while haters call old and dated) have features that aren't accessible in other editors at all or without buggy plugins etc. Here I will document my findings and how I am currently using vim / ctags /cgdb and the typical jdk to develop an Android game.  I will assume you have both the latest Android SDK and NDK installed and your environment is working correctly (also you will probably want the ...