README.android
changeset 6650 d36232135316
parent 6646 dd32cce44d3c
child 6652 bb2a33ed8688
     1.1 --- a/README.android	Sun Nov 04 09:45:18 2012 -0800
     1.2 +++ b/README.android	Sun Nov 04 13:49:32 2012 -0800
     1.3 @@ -48,7 +48,7 @@
     1.4  5. Edit <project>/local.properties to point to the Android SDK directory
     1.5  6. Run 'ant debug' in android/project. This compiles the .java and eventually 
     1.6  creates a .apk with the native code embedded
     1.7 -7. 'ant install' will push the apk to the device or emulator (if connected)
     1.8 +7. 'ant debug install' will push the apk to the device or emulator (if connected)
     1.9  
    1.10  Here's an explanation of the files in the Android project, so you can customize them:
    1.11  
    1.12 @@ -276,6 +276,50 @@
    1.13  
    1.14  
    1.15  ================================================================================
    1.16 + Memory debugging
    1.17 +================================================================================
    1.18 +
    1.19 +The best (and slowest) way to debug memory issues on Android is valgrind.
    1.20 +Valgrind has support for Android out of the box, just grab code using:
    1.21 +	svn co svn://svn.valgrind.org/valgrind/trunk valgrind
    1.22 +... and follow the instructions in the file README.android to build it.
    1.23 +
    1.24 +One thing I needed to do on Mac OS X was change the path to the toolchain,
    1.25 +and add ranlib to the environment variables:
    1.26 +export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
    1.27 +
    1.28 +Once valgrind is built, you can create a wrapper script to launch your
    1.29 +application with it, changing org.libsdl.app to your package identifier:
    1.30 +--- start_valgrind_app -------------------
    1.31 +#!/system/bin/sh
    1.32 +export TMPDIR=/data/data/org.libsdl.app
    1.33 +exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
    1.34 +------------------------------------------
    1.35 +
    1.36 +Then push it to the device:
    1.37 +	adb push start_valgrind_app /data/local
    1.38 +
    1.39 +and make it executable:
    1.40 +	adb shell chmod 755 /data/local/start_valgrind_app
    1.41 +
    1.42 +and tell Android to use the script to launch your application:
    1.43 +	adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
    1.44 +
    1.45 +If the setprop command says "could not set property", it's likely that
    1.46 +your package name is too long and you should make it shorter by changing
    1.47 +AndroidManifest.xml and the path to your class file in android-project/src
    1.48 +
    1.49 +You can then launch your application normally and waaaaaaaiiittt for it.
    1.50 +You can monitor the startup process with the logcat command above, and
    1.51 +when it's done (or even while it's running) you can grab the valgrind
    1.52 +output file:
    1.53 +	adb pull /sdcard/valgrind.log
    1.54 +
    1.55 +When you're done instrumenting with valgrind, you can disable the wrapper:
    1.56 +	adb shell setprop wrap.org.libsdl.app ""
    1.57 +
    1.58 +
    1.59 +================================================================================
    1.60   Known issues
    1.61  ================================================================================
    1.62