Wednesday, March 20, 2013

[Android] Easy Logging

From the Java ( log to logcat)

import android.util.Log

Log.w("myApp", "My Message");

From the NDK/Native side ( still logs to logcat)

#include
#define APPNAME "MyApp"


__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "MyMessage\n");

also remember to add the following to Android.mk

LD_LDFLAGS := -llog

Monday, March 11, 2013

[Android] undefined references

If you get a ton of undefined references, for methods/functions that you're sure are defined. Make sure to add:

"LOCAL_ALLOW_UNDEFINED_SYMBOLS := true" to your Android.mk file.

Reasoning is given here:

http://stackoverflow.com/questions/7209971/ndk-build-undefined-reference-to-errors-when-statically-linking-to-libxml-a

[Android] Note: limits: No such file or directory

If you get the following error:

fatal error: limits: No such file or directory

Or

error: 'numeric_limits' is not a member of 'std'

The solution is to include ( not or ). Then add

"APP_STL := stlport_static" to your jni/Application.mk 

Adding it to your Android.mk file does not work. I created an Application.mk file, with just that line and it worked.

Solution from:

https://groups.google.com/forum/#!msg/android-ndk/4cIVid0P3go/LY3htUx_qMgJ

[Android] Note: Device Not Showing up in ADC

If DDMS is seeing the device, but eclipse/Android Device Chooser is not showing it then check to see if the project requires a more up to date SDK version.