annotate README.android @ 4966:a130bc2f0a18

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