README.android
author Sam Lantinga <slouken@libsdl.org>
Thu, 06 Jan 2011 16:11:21 -0800
changeset 4964 6c645018741e
parent 4954 144d9df7e611
child 4965 91d0085b7560
permissions -rw-r--r--
Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
     5
Requirements: Android SDK and Android NDK r4 or later
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
     6
http://developer.android.com/
4725
4eb9d3c7fdd2 Added initial README.android
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
     7
4727
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
     8
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
     9
 How the port works
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    10
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    11
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    12
- Android applications are Java-based, optionally with parts written in C
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    13
- 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
    14
the SDL library
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    15
- 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
    16
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
    17
- This eventually produces a standard Android .apk package
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    18
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    19
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    20
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    21
 Building an app
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    22
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    23
4725
4eb9d3c7fdd2 Added initial README.android
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    24
Instructions:
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
    25
1. Copy the android-project directory wherever you want your Android project to go
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
    26
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
    27
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
    28
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
    29
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
    30
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
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
    32
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
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
    34
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
    35
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
    36
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
    37
4eb9d3c7fdd2 Added initial README.android
Paul Hunkin <paul@bieh.net>
parents:
diff changeset
    38
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
    39
================================================================================
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
 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
    41
================================================================================
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
    42
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
    43
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
    44
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
    45
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
    46
================================================================================
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
    47
 Loading files
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
    48
================================================================================
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
    49
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
    50
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
    51
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
    52
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
    53
================================================================================
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
    54
 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
    55
================================================================================
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
    56
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
    57
NEED CONTENT
4727
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    58
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    59
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    60
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    61
 Known issues
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    62
================================================================================
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    63
8087bb208acf Updated the readme
Paul Hunkin <paul@bieh.net>
parents: 4726
diff changeset
    64
- 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
    65
- TODO. I'm sure there's a bunch more stuff I haven't thought of