README.android
author Sam Lantinga <slouken@libsdl.org>
Thu, 06 Jan 2011 17:12:31 -0800
changeset 4965 91d0085b7560
parent 4964 6c645018741e
child 4967 f74a3f94c408
permissions -rw-r--r--
Added the Android project and lots of info to README.android
     1 ================================================================================
     2 Simple DirectMedia Layer for Android
     3 ================================================================================
     4 
     5 Requirements:
     6 
     7 Android SDK
     8 http://developer.android.com/sdk/index.html
     9 
    10 Android NDK r4 or later
    11 http://developer.android.com/sdk/ndk/index.html
    12 
    13 ================================================================================
    14  How the port works
    15 ================================================================================
    16 
    17 - Android applications are Java-based, optionally with parts written in C
    18 - As SDL apps are C-based, we use a small Java shim that uses JNI to talk to 
    19 the SDL library
    20 - This means that your application C code must be placed inside an android 
    21 Java project, along with some C support code that communicates with Java
    22 - This eventually produces a standard Android .apk package
    23 
    24 
    25 ================================================================================
    26  Building an app
    27 ================================================================================
    28 
    29 Instructions:
    30 1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project.
    31 2. Move this SDL directory into the <project>/jni directory
    32 3. Place your application source files in the <project>/jni/src directory
    33 4. Edit <project>/jni/src/Android.mk to include your source files
    34 5. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
    35 
    36 If you want to use the Eclipse IDE, skip to the Eclipse section below.
    37 
    38 6. Edit <project>/local.properties to point to the Android SDK directory
    39 7. Run 'ant debug' in android/project. This compiles the .java and eventually 
    40 creates a .apk with the native code embedded
    41 8. 'ant install' will push the apk to the device or emulator (if connected)
    42 
    43 Here's an explanation of the files in the Android project, so you can customize them:
    44 
    45 android-project/
    46 	AndroidManifest.xml	- package manifest, do not modify
    47 	build.properties	- empty
    48 	build.xml		- build description file, used by ant
    49 	default.properties	- holds the ABI for the application, currently android-4 which corresponds to the Android 1.6 system image
    50 	local.properties	- holds the SDK path, you should change this to the path to your SDK
    51 	jni/			- directory holding native code and Android.mk
    52 	jni/Android.mk		- Android makefile that includes all subdirectories
    53 	jni/SDL/		- directory holding the SDL library files
    54 	jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
    55 	jni/src/		- directory holding your application source
    56 	jni/src/Android.mk	- Android makefile that you should customize to include your source code and any library references
    57 	res/			- directory holding resources for your application
    58 	res/drawable-*		- directories holding icons for different phone hardware
    59 	res/layout/main.xml	- place holder for the main screen layout, overridden by the SDL video output
    60 	res/values/strings.xml	- strings used in your application, including the application name shown on the phone.
    61 	src/org/libsdl/app/SDLActivity.java	- the Java class handling the initialization and binding to SDL.  Be very careful changing this, as the SDL library relies on this implementation.
    62 
    63 
    64 ================================================================================
    65  Additional documentation
    66 ================================================================================
    67 
    68 The documentation in the NDK docs directory is very helpful in understanding the build process and how to work with native code on the Android platform.
    69 
    70 The best place to start is with docs/OVERVIEW.TXT
    71 
    72 
    73 ================================================================================
    74  Using Eclipse
    75 ================================================================================
    76 
    77 First make sure that you've installed Eclipse and the Android extensions as described here:
    78 	http://developer.android.com/sdk/eclipse-adt.html
    79 
    80 Once you've copied the SDL android project and customized it, you can create an Eclipse project from it:
    81  * File -> New -> Other
    82  * Select the Android -> Android Project wizard and click Next
    83  * Enter the name you'd like your project to have
    84  * Select "Create project from existing source" and browse for your project directory
    85  * Make sure the Build Target is set to Android 1.6
    86  * Click Finish
    87 
    88 
    89 ================================================================================
    90  Loading files and resources
    91 ================================================================================
    92 
    93 NEED CONTENT
    94 
    95 
    96 ================================================================================
    97  Troubleshooting
    98 ================================================================================
    99 
   100 You can create and run an emulator from the Eclipse IDE:
   101  * Window -> Android SDK and AVD Manager
   102 
   103 You can see if adb can see any devices with the following command:
   104 	adb devices
   105 
   106 You can see the output of log messages on the default device with:
   107 	adb logcat
   108 
   109 You can push files to the device with:
   110 	adb push local_file remote_path_and_file
   111 
   112 You can push files to the SD Card at /sdcard, for example:
   113 	adb push moose.dat /sdcard/moose.dat
   114 
   115 
   116 ================================================================================
   117  Known issues
   118 ================================================================================
   119 
   120 - SDL audio (although it's mostly written, just not working properly yet)
   121 - TODO. I'm sure there's a bunch more stuff I haven't thought of