1.1 --- a/docs/README-android.md Mon Aug 11 17:25:53 2014 -0700
1.2 +++ b/docs/README-android.md Tue Aug 12 23:28:45 2014 +0200
1.3 @@ -81,33 +81,33 @@
1.4
1.5 Here's an explanation of the files in the Android project, so you can customize them:
1.6
1.7 -android-project/
1.8 - AndroidManifest.xml - package manifest. Among others, it contains the class name
1.9 - of the main Activity and the package name of the application.
1.10 - build.properties - empty
1.11 - build.xml - build description file, used by ant. The actual application name
1.12 - is specified here.
1.13 - default.properties - holds the target ABI for the application, android-10 and up
1.14 - project.properties - holds the target ABI for the application, android-10 and up
1.15 - local.properties - holds the SDK path, you should change this to the path to your SDK
1.16 - jni/ - directory holding native code
1.17 - jni/Android.mk - Android makefile that can call recursively the Android.mk files
1.18 - in all subdirectories
1.19 - jni/SDL/ - (symlink to) directory holding the SDL library files
1.20 - jni/SDL/Android.mk - Android makefile for creating the SDL shared library
1.21 - jni/src/ - directory holding your C/C++ source
1.22 - jni/src/Android.mk - Android makefile that you should customize to include your
1.23 + android-project/
1.24 + AndroidManifest.xml - package manifest. Among others, it contains the class name
1.25 + of the main Activity and the package name of the application.
1.26 + build.properties - empty
1.27 + build.xml - build description file, used by ant. The actual application name
1.28 + is specified here.
1.29 + default.properties - holds the target ABI for the application, android-10 and up
1.30 + project.properties - holds the target ABI for the application, android-10 and up
1.31 + local.properties - holds the SDK path, you should change this to the path to your SDK
1.32 + jni/ - directory holding native code
1.33 + jni/Android.mk - Android makefile that can call recursively the Android.mk files
1.34 + in all subdirectories
1.35 + jni/SDL/ - (symlink to) directory holding the SDL library files
1.36 + jni/SDL/Android.mk - Android makefile for creating the SDL shared library
1.37 + jni/src/ - directory holding your C/C++ source
1.38 + jni/src/Android.mk - Android makefile that you should customize to include your
1.39 source code and any library references
1.40 - res/ - directory holding resources for your application
1.41 - res/drawable-* - directories holding icons for different phone hardware. Could be
1.42 - one dir called "drawable".
1.43 - res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout.
1.44 - We don't need it because we use the SDL video output.
1.45 - res/values/strings.xml - strings used in your application, including the application name
1.46 - shown on the phone.
1.47 - src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
1.48 - to SDL. Be very careful changing this, as the SDL library relies
1.49 - on this implementation.
1.50 + res/ - directory holding resources for your application
1.51 + res/drawable-* - directories holding icons for different phone hardware. Could be
1.52 + one dir called "drawable".
1.53 + res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout.
1.54 + We don't need it because we use the SDL video output.
1.55 + res/values/strings.xml - strings used in your application, including the application name
1.56 + shown on the phone.
1.57 + src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
1.58 + to SDL. Be very careful changing this, as the SDL library relies
1.59 + on this implementation.
1.60
1.61
1.62 ================================================================================
1.63 @@ -141,6 +141,7 @@
1.64
1.65 Then create a Java class extending SDLActivity and place it in a directory
1.66 under src matching your package, e.g.
1.67 +
1.68 src/com/gamemaker/game/MyGame.java
1.69
1.70 Here's an example of a minimal class file:
1.71 @@ -291,30 +292,39 @@
1.72 * Window -> Android SDK and AVD Manager
1.73
1.74 You can see if adb can see any devices with the following command:
1.75 +
1.76 adb devices
1.77
1.78 You can see the output of log messages on the default device with:
1.79 +
1.80 adb logcat
1.81
1.82 You can push files to the device with:
1.83 +
1.84 adb push local_file remote_path_and_file
1.85
1.86 You can push files to the SD Card at /sdcard, for example:
1.87 +
1.88 adb push moose.dat /sdcard/moose.dat
1.89
1.90 You can see the files on the SD card with a shell command:
1.91 +
1.92 adb shell ls /sdcard/
1.93
1.94 You can start a command shell on the default device with:
1.95 +
1.96 adb shell
1.97
1.98 You can remove the library files of your project (and not the SDL lib files) with:
1.99 +
1.100 ndk-build clean
1.101
1.102 You can do a build with the following command:
1.103 +
1.104 ndk-build
1.105
1.106 You can see the complete command line that ndk-build is using by passing V=1 on the command line:
1.107 +
1.108 ndk-build V=1
1.109
1.110 If your application crashes in native code, you can use addr2line to convert the
1.111 @@ -334,7 +344,9 @@
1.112
1.113 You can see that there's a crash in the C library being called from the main code.
1.114 I run addr2line with the debug version of my code:
1.115 +
1.116 arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
1.117 +
1.118 and then paste in the number after "pc" in the call stack, from the line that I care about:
1.119 000014bc
1.120
1.121 @@ -342,9 +354,9 @@
1.122
1.123 You can add logging to your code to help show what's happening:
1.124
1.125 -#include <android/log.h>
1.126 -
1.127 - __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
1.128 + #include <android/log.h>
1.129 +
1.130 + __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
1.131
1.132 If you need to build without optimization turned on, you can create a file called
1.133 "Application.mk" in the jni directory, with the following line in it:
1.134 @@ -357,7 +369,9 @@
1.135
1.136 The best (and slowest) way to debug memory issues on Android is valgrind.
1.137 Valgrind has support for Android out of the box, just grab code using:
1.138 +
1.139 svn co svn://svn.valgrind.org/valgrind/trunk valgrind
1.140 +
1.141 ... and follow the instructions in the file README.android to build it.
1.142
1.143 One thing I needed to do on Mac OS X was change the path to the toolchain,
1.144 @@ -374,12 +388,15 @@
1.145 ------------------------------------------
1.146
1.147 Then push it to the device:
1.148 +
1.149 adb push start_valgrind_app /data/local
1.150
1.151 and make it executable:
1.152 +
1.153 adb shell chmod 755 /data/local/start_valgrind_app
1.154
1.155 and tell Android to use the script to launch your application:
1.156 +
1.157 adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
1.158
1.159 If the setprop command says "could not set property", it's likely that
1.160 @@ -390,9 +407,11 @@
1.161 You can monitor the startup process with the logcat command above, and
1.162 when it's done (or even while it's running) you can grab the valgrind
1.163 output file:
1.164 +
1.165 adb pull /sdcard/valgrind.log
1.166
1.167 When you're done instrumenting with valgrind, you can disable the wrapper:
1.168 +
1.169 adb shell setprop wrap.org.libsdl.app ""
1.170
1.171 ================================================================================