Android SDK ADT Bundle

ついにAndroid SDKに、Eclipseが含まれるようになった。しかもNDKも1つのプロジェクトでビルドできる。

adt-bundle-windows-x86_64-20130219.zipをダウンロードする。

http://developer.android.com/sdk/index.html

android-ndk-r8e-windows-x86_64.zipもダウンロードする。

http://developer.android.com/tools/sdk/ndk/index.html

C:\に解凍してリネームする。

C:\android-sdk-windows
C:\android-ndk-r8e

Android SDKに含まれるEclipseを起動してworkspaceを作成する。

C:\workspace

Window>Android SDK ManagerにてAPIレベル4をインストールする。

Window>Preferenses>Android>NDKでNDK Locationを設定する。

Window>Preferenses>C/C++>Code Analisysのチェックは全て外す。



次にSDLのサイトからandroid-project.zipをダウンロードして解凍する。

http://www.libsdl.org/tmp/android-project.zip

C:\android-project

以下のフォルダは不要なので削除する。

C:\android-project\jni\SDL_image
C:\android-project\jni\SDL_mixer
C:\android-project\jni\SDL_net
C:\android-project\jni\SDL_ttf
C:\android-project\jni\mikmod
C:\android-project\jni\freetype
C:\android-project\jni\png
C:\android-project\jni\jpeg
C:\android-project\jni\tremor

C:\android-project\src\org\libsdl.app\SDLActivity.java

    // Load the .so
    static {
        System.loadLibrary("SDL");
///        System.loadLibrary("SDL_image");
///        System.loadLibrary("mikmod");
///        System.loadLibrary("SDL_mixer");
///        System.loadLibrary("SDL_ttf");
        System.loadLibrary("main");
    }

APIレベル4なのでOpenGLESv2は利用出来ない。

C:\android-project\jni\SDL\Android.mk

###LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog
LOCAL_LDLIBS := -ldl -lGLESv1_CM -llog

C:\android-project\jni\SDL\include\SDL_config_android.h

///#define SDL_VIDEO_RENDER_OGL_ES2	1
#define SDL_VIDEO_RENDER_OGL_ES2	0

C:\android-project\default.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# 
# This file must be checked in Version Control Systems.
# 
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
#target=android-7
target=android-4

C:\android-project\localproperties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# 
# This file must *NOT* be checked in Version Control Systems,
# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
#sdk.dir=/Users/hercules/eclipse/android-sdk-mac_86
sdk.dir=C:\\android-sdk-windows

画面の向き、SDカードへの書き込みなどを設定する。

C:\android-project\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.libsdl.app"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
        <activity android:name="SDLActivity"
                  android:label="@string/app_name" android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest> 

File>New>Other>Android project from Existing Codeで、Copy projects into workspaceにチェックを入れてを読み込むと以下のフォルダが生成される。

C:\workspace\SDLActivity

Package ExplolerからSDLActivityを右クリックして、Android Tools>Add Native Support...>libmain.soでC/C++コードもビルド出来るようにする。