Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
121 lines (88 loc) · 5.38 KB

README.android

File metadata and controls

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