Switched to new style gradle Android application build process

This commit is contained in:
Sam Lantinga 2017-10-23 15:23:43 -07:00
parent 862da6ff19
commit f08480af78
36 changed files with 567 additions and 328 deletions

View File

@ -1,17 +0,0 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

112
android-project/app/app.iml Normal file
View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.2.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
</component>
</module>

View File

@ -0,0 +1,35 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "org.libsdl.app"
minSdkVersion 10
targetSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}

View File

@ -1,10 +1,9 @@
# Uncomment this if you're using STL in your project # Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information # See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
# APP_STL := stlport_static # APP_STL := stlport_static
APP_ABI := armeabi armeabi-v7a x86 APP_ABI := all
# Min SDK level # Min SDK level
APP_PLATFORM=android-10 APP_PLATFORM=android-10

View File

@ -1,11 +1,8 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here. # Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified # By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt # in [sdk]/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard # You can edit the include path and order by changing the proguardFiles
# include property in project.properties. # directive in build.gradle.
# #
# For more details, see # For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html # http://developer.android.com/guide/developing/tools/proguard.html

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Replace org.libsdl.app with the identifier of your game below, e.g. <!-- Replace com.test.game with the identifier of your game below, e.g.
com.gamemaker.game com.gamemaker.game
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libsdl.app" package="org.libsdl.app"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" android:versionName="1.0"
android:installLocation="auto"> android:installLocation="auto">
<!-- Android 2.3.3 --> <!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="12" /> <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="25" />
<!-- OpenGL ES 2.0 --> <!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" /> <uses-feature android:glEsVersion="0x00020000" />
@ -23,23 +23,22 @@
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> --> <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<!-- Create a Java class extending SDLActivity and place it in a <!-- Create a Java class extending SDLActivity and place it in a
directory under src matching the package, e.g. directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
src/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame") then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below. in the XML below.
An example Java class can be found in README-android.md An example Java class can be found in README-android.md
--> -->
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/ic_launcher" android:icon="@mipmap/ic_launcher"
android:allowBackup="true" android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true" > android:hardwareAccelerated="true" >
<activity android:name="SDLActivity" <activity android:name="SDLActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -55,4 +54,4 @@
</activity> </activity>
</application> </application>
</manifest> </manifest>

View File

@ -36,7 +36,7 @@ public class SDLActivity extends Activity {
// Handle the state of the native layer // Handle the state of the native layer
public enum NativeState { public enum NativeState {
INIT, RESUMED, PAUSED INIT, RESUMED, PAUSED
} }
public static NativeState mNextNativeState; public static NativeState mNextNativeState;
@ -208,7 +208,7 @@ public class SDLActivity extends Activity {
mLayout.addView(mSurface); mLayout.addView(mSurface);
setContentView(mLayout); setContentView(mLayout);
// Get filename from "Open with" of another application // Get filename from "Open with" of another application
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null && intent.getData() != null) { if (intent != null && intent.getData() != null) {
@ -265,7 +265,7 @@ public class SDLActivity extends Activity {
} else { } else {
mNextNativeState = NativeState.PAUSED; mNextNativeState = NativeState.PAUSED;
} }
SDLActivity.handleNativeState(); SDLActivity.handleNativeState();
} }
@ -542,7 +542,7 @@ public class SDLActivity extends Activity {
{ {
int orientation = -1; int orientation = -1;
if (!Objects.equals(hint, "")) { if (hint != "") {
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
} else if (hint.contains("LandscapeRight")) { } else if (hint.contains("LandscapeRight")) {
@ -1152,7 +1152,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate()); SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate());
Log.v("SDL", "Window size: " + width + "x" + height); Log.v("SDL", "Window size: " + width + "x" + height);
boolean skip = false; boolean skip = false;
int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
@ -1175,7 +1175,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
if (skip) { if (skip) {
double min = Math.min(mWidth, mHeight); double min = Math.min(mWidth, mHeight);
double max = Math.max(mWidth, mHeight); double max = Math.max(mWidth, mHeight);
if (max / min < 1.20) { if (max / min < 1.20) {
Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution.");
skip = false; skip = false;
@ -1187,7 +1187,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
SDLActivity.mIsSurfaceReady = false; SDLActivity.mIsSurfaceReady = false;
return; return;
} }
/* Surface is ready */ /* Surface is ready */
SDLActivity.mIsSurfaceReady = true; SDLActivity.mIsSurfaceReady = true;

View File

@ -266,7 +266,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
public String getJoystickDescriptor(InputDevice joystickDevice) { public String getJoystickDescriptor(InputDevice joystickDevice) {
String desc = joystickDevice.getDescriptor(); String desc = joystickDevice.getDescriptor();
if (desc != null && !Objects.equals(desc, "")) { if (desc != null && desc != "") {
return desc; return desc;
} }

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">Game</string>
</resources>

View File

@ -0,0 +1,8 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -1,17 +0,0 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This should be changed to the name of your project -->
<project name="SDLActivity" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,11 +0,0 @@
# 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-16

View File

@ -0,0 +1,17 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Mon Oct 23 13:51:26 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

160
android-project/gradlew vendored Executable file
View File

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
android-project/gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,12 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := YourSourceHere.c
LOCAL_STATIC_LIBRARIES := SDL2_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,SDL)LOCAL_PATH := $(call my-dir)

View File

@ -1,14 +0,0 @@
# 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 edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-16

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, SDLActivity"
/>
</LinearLayout>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SDL App</string>
</resources>

View File

@ -0,0 +1 @@
include ':app'

View File

@ -33,25 +33,26 @@ fi
SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )" SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
if [ -z "$ANDROID_HOME" ];then
echo "Please set the ANDROID_HOME directory to the path of the Android SDK"
exit 1
fi
NDKBUILD=`which ndk-build` NDKBUILD=`which ndk-build`
if [ -z "$NDKBUILD" ];then if [ -z "$NDKBUILD" ];then
echo "Could not find the ndk-build utility, install Android's NDK and add it to the path" echo "Could not find the ndk-build utility, install Android's NDK and add it to the path"
exit 1 exit 1
fi fi
ANDROID=`which android` ANDROID="$ANDROID_HOME/tools/android"
if [ ! -f "$ANDROID" ]; then
ANDROID=`which android`
fi
if [ -z "$ANDROID" ];then if [ -z "$ANDROID" ];then
echo "Could not find the android utility, install Android's SDK and add it to the path" echo "Could not find the android utility, install Android's SDK and add it to the path"
exit 1 exit 1
fi fi
ANT=`which ant`
if [ -z "$ANT" ];then
echo "Could not find the ant utility, install Android's SDK and add it to the path"
exit 1
fi
NCPUS="1" NCPUS="1"
case "$OSTYPE" in case "$OSTYPE" in
darwin*) darwin*)
@ -77,27 +78,28 @@ mkdir -p $BUILDPATH
cp -r $SDLPATH/android-project/* $BUILDPATH cp -r $SDLPATH/android-project/* $BUILDPATH
# Copy SDL sources # Copy SDL sources
mkdir -p $BUILDPATH/jni/SDL mkdir -p $BUILDPATH/app/jni/SDL
if [ -z "$COPYSOURCE" ]; then if [ -z "$COPYSOURCE" ]; then
ln -s $SDLPATH/src $BUILDPATH/jni/SDL ln -s $SDLPATH/src $BUILDPATH/app/jni/SDL
ln -s $SDLPATH/include $BUILDPATH/jni/SDL ln -s $SDLPATH/include $BUILDPATH/app/jni/SDL
else else
cp -r $SDLPATH/src $BUILDPATH/jni/SDL cp -r $SDLPATH/src $BUILDPATH/app/jni/SDL
cp -r $SDLPATH/include $BUILDPATH/jni/SDL cp -r $SDLPATH/include $BUILDPATH/app/jni/SDL
fi fi
cp -r $SDLPATH/Android.mk $BUILDPATH/jni/SDL cp -r $SDLPATH/Android.mk $BUILDPATH/app/jni/SDL
sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/jni/src/Android.mk sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/app/jni/src/Android.mk
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/AndroidManifest.xml sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/build.gradle
sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/app/src/main/AndroidManifest.xml
# Copy user sources # Copy user sources
for src in "${SOURCES[@]}" for src in "${SOURCES[@]}"
do do
cp $src $BUILDPATH/jni/src cp $src $BUILDPATH/app/jni/src
done done
# Create an inherited Activity # Create an inherited Activity
cd $BUILDPATH/src cd $BUILDPATH/app/src/main/java
for folder in "${APPARR[@]}" for folder in "${APPARR[@]}"
do do
mkdir -p $folder mkdir -p $folder
@ -105,31 +107,38 @@ do
done done
ACTIVITY="${folder}Activity" ACTIVITY="${folder}Activity"
sed -i -e "s|SDLActivity|$ACTIVITY|g" $BUILDPATH/AndroidManifest.xml sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" $BUILDPATH/app/src/main/AndroidManifest.xml
sed -i -e "s|SDLActivity|$APP|g" $BUILDPATH/build.xml
# Fill in a default Activity # Fill in a default Activity
echo "package $APP;" > "$ACTIVITY.java" cat >"$ACTIVITY.java" <<__EOF__
echo "import org.libsdl.app.SDLActivity;" >> "$ACTIVITY.java" package $APP;
echo "public class $ACTIVITY extends SDLActivity {}" >> "$ACTIVITY.java"
import org.libsdl.app.SDLActivity;
public class $ACTIVITY extends SDLActivity
{
}
__EOF__
# Update project and build # Update project and build
cd $BUILDPATH cd $BUILDPATH
$ANDROID update project --path $BUILDPATH pushd $BUILDPATH/app/jni
$NDKBUILD -j $NCPUS $NDKARGS $NDKBUILD -j $NCPUS $NDKARGS
$ANT debug popd
# Start gradle build
$BUILDPATH/gradlew build
cd $CURDIR cd $CURDIR
APK="$BUILDPATH/bin/$APP-debug.apk" APK="$BUILDPATH/app/build/outputs/apk/app-debug.apk"
if [ -f "$APK" ]; then if [ -f "$APK" ]; then
echo "Your APK is ready at $APK" echo "Your APK is ready at $APK"
echo "To install to your device: " echo "To install to your device: "
echo "cd $BUILDPATH" echo "$ANDROID_HOME/platform-tools/adb install -r $APK"
echo "ant debug install"
exit 0 exit 0
fi fi
echo "There was an error building the APK" echo "There was an error building the APK"
exit 1 exit 1

View File

@ -4,7 +4,8 @@ Android
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio: Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
The rest of this README covers the old style build process. The rest of this README covers the traditional style build process.
================================================================================ ================================================================================
Requirements Requirements
@ -19,6 +20,7 @@ https://developer.android.com/tools/sdk/ndk/index.html
Minimum API level supported by SDL: 10 (Android 2.3.3) Minimum API level supported by SDL: 10 (Android 2.3.3)
Joystick support is available for API level >= 12 devices. Joystick support is available for API level >= 12 devices.
================================================================================ ================================================================================
How the port works How the port works
================================================================================ ================================================================================
@ -31,15 +33,12 @@ Joystick support is available for API level >= 12 devices.
- This eventually produces a standard Android .apk package - This eventually produces a standard Android .apk package
The Android Java code implements an "Activity" and can be found in: The Android Java code implements an "Activity" and can be found in:
android-project/src/org/libsdl/app/SDLActivity.java android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
The Java code loads your game code, the SDL shared library, and The Java code loads your game code, the SDL shared library, and
dispatches to native functions implemented in the SDL library: dispatches to native functions implemented in the SDL library:
src/core/android/SDL_android.c src/core/android/SDL_android.c
Your project must include some glue code that starts your main() routine:
src/main/android/SDL_android_main.c
================================================================================ ================================================================================
Building an app Building an app
@ -74,71 +73,32 @@ For more complex projects, follow these instructions:
1. Copy the android-project directory wherever you want to keep your projects 1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project. and rename it to the name of your project.
2. Move or symlink this SDL directory into the "<project>/jni" directory 2. Move or symlink this SDL directory into the "<project>/app/jni" directory
3. Edit "<project>/jni/src/Android.mk" to include your source files 3. Edit "<project>/app/jni/src/Android.mk" to include your source files
4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source 4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
If you want to use the Eclipse IDE, skip to the Eclipse section below. If you want to use Android Studio (recommended), skip to the Android Studio section below.
5. Create "<project>/local.properties" and use that to point to the Android SDK directory, by writing a line with the following form: 5. Run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
sdk.dir=PATH_TO_ANDROID_SDK
6. Run 'ant debug' in android/project. This compiles the .java and eventually
creates a .apk with the native code embedded
7. 'ant debug install' will push the apk to the device or emulator (if connected)
Here's an explanation of the files in the Android project, so you can customize them: Here's an explanation of the files in the Android project, so you can customize them:
android-project/ android-project/app
AndroidManifest.xml - package manifest. Among others, it contains the class name build.gradle - build info including the application version and SDK
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name
of the main Activity and the package name of the application. of the main Activity and the package name of the application.
build.properties - empty
build.xml - build description file, used by ant. The actual application name
is specified here.
default.properties - holds the target ABI for the application, android-10 and up
project.properties - holds the target ABI for the application, android-10 and up
local.properties - holds the SDK path, you should change this to the path to your SDK
jni/ - directory holding native code jni/ - directory holding native code
jni/Android.mk - Android makefile that can call recursively the Android.mk files jni/Application.mk - Application JNI settings, including target platform and STL library
in all subdirectories jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
jni/SDL/ - (symlink to) directory holding the SDL library files jni/SDL/ - (symlink to) directory holding the SDL library files
jni/SDL/Android.mk - Android makefile for creating the SDL shared library jni/SDL/Android.mk - Android makefile for creating the SDL shared library
jni/src/ - directory holding your C/C++ source jni/src/ - directory holding your C/C++ source
jni/src/Android.mk - Android makefile that you should customize to include your jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
source code and any library references src/main/assets/ - directory holding asset files for your application
res/ - directory holding resources for your application src/main/res/ - directory holding resources for your application
res/drawable-* - directories holding icons for different phone hardware. Could be src/main/res/mipmap-* - directories holding icons for different phone hardware
one dir called "drawable". src/main/res/values/strings.xml - strings used in your application, including the application name
res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout. src/main/java/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. You should instead subclass this for your application.
We don't need it because we use 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.
================================================================================
Build an app with static linking of libSDL
================================================================================
This build uses the Android NDK module system.
Instructions:
1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project.
2. Rename "<project>/jni/src/Android_static.mk" to "<project>/jni/src/Android.mk"
(overwrite the existing one)
3. Edit "<project>/jni/src/Android.mk" to include your source files
4. create and export an environment variable named NDK_MODULE_PATH that points
to the parent directory of this SDL directory. e.g.:
export NDK_MODULE_PATH="$PWD"/..
5. Edit "<project>/src/org/libsdl/app/SDLActivity.java" and remove the call to
System.loadLibrary("SDL2").
6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
================================================================================ ================================================================================
@ -171,25 +131,23 @@ Here's an example of a minimal class file:
Then replace "SDLActivity" in AndroidManifest.xml with the name of your Then replace "SDLActivity" in AndroidManifest.xml with the name of your
class, .e.g. "MyGame" class, .e.g. "MyGame"
================================================================================ ================================================================================
Customizing your application icon Customizing your application icon
================================================================================ ================================================================================
Conceptually changing your icon is just replacing the "ic_launcher.png" files in Conceptually changing your icon is just replacing the "ic_launcher.png" files in
the drawable directories under the res directory. There are four directories for the drawable directories under the res directory. There are several directories
different screen sizes. These can be replaced with one dir called "drawable", for different screen sizes.
containing an icon file "ic_launcher.png" with dimensions 48x48 or 72x72.
You may need to change the name of your icon in AndroidManifest.xml to match
this icon filename.
================================================================================ ================================================================================
Loading assets Loading assets
================================================================================ ================================================================================
Any files you put in the "assets" directory of your android-project directory Any files you put in the "app/src/main/assets" directory of your project
will get bundled into the application package and you can load them using the directory will get bundled into the application package and you can load
standard functions in SDL_rwops.h. them using the standard functions in SDL_rwops.h.
There are also a few Android specific functions that allow you to get other There are also a few Android specific functions that allow you to get other
useful paths for saving and loading data: useful paths for saving and loading data:
@ -211,6 +169,7 @@ disable this behaviour, see for example:
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/ http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
================================================================================ ================================================================================
Pause / Resume behaviour Pause / Resume behaviour
================================================================================ ================================================================================
@ -231,6 +190,7 @@ a specific message, (which is not yet implemented!) and restore your textures
manually or quit the app (which is actually the kind of behaviour you'll see manually or quit the app (which is actually the kind of behaviour you'll see
under iOS, if the OS can not restore your GL context it will just kill your app) under iOS, if the OS can not restore your GL context it will just kill your app)
================================================================================ ================================================================================
Threads and the Java VM Threads and the Java VM
================================================================================ ================================================================================
@ -246,6 +206,7 @@ Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
your thread automatically anyway (when you make an SDL call), but it'll never your thread automatically anyway (when you make an SDL call), but it'll never
detach it. detach it.
================================================================================ ================================================================================
Using STL Using STL
================================================================================ ================================================================================
@ -257,6 +218,7 @@ folder and adding the following line:
For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation. For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
================================================================================ ================================================================================
Additional documentation Additional documentation
================================================================================ ================================================================================
@ -268,19 +230,10 @@ The best place to start is with docs/OVERVIEW.TXT
================================================================================ ================================================================================
Using Eclipse Using Android Studio
================================================================================ ================================================================================
First make sure that you've installed Eclipse and the Android extensions as described here: You can open your project directory with Android Studio and run it normally.
https://developer.android.com/tools/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 3.1 (API 12)
* Click Finish
================================================================================ ================================================================================
@ -295,13 +248,11 @@ Especially useful is the info on setting up OpenGL ES 2.0 emulation.
Notice that this software emulator is incredibly slow and needs a lot of disk space. Notice that this software emulator is incredibly slow and needs a lot of disk space.
Using a real device works better. Using a real device works better.
================================================================================ ================================================================================
Troubleshooting Troubleshooting
================================================================================ ================================================================================
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: You can see if adb can see any devices with the following command:
adb devices adb devices
@ -426,19 +377,21 @@ When you're done instrumenting with valgrind, you can disable the wrapper:
adb shell setprop wrap.org.libsdl.app "" adb shell setprop wrap.org.libsdl.app ""
================================================================================ ================================================================================
Graphics debugging Graphics debugging
================================================================================ ================================================================================
If you are developing on a compatible Tegra-based tablet, NVidia provides If you are developing on a compatible Tegra-based tablet, NVidia provides
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
and GLES libraries, you must follow their instructions for installing the and GLES libraries, you must follow their instructions for installing the
interposer library on a rooted device. The non-rooted instructions are not interposer library on a rooted device. The non-rooted instructions are not
compatible with applications that use SDL2 for video. compatible with applications that use SDL2 for video.
The Tegra Graphics Debugger is available from NVidia here: The Tegra Graphics Debugger is available from NVidia here:
https://developer.nvidia.com/tegra-graphics-debugger https://developer.nvidia.com/tegra-graphics-debugger
================================================================================ ================================================================================
Why is API level 10 the minimum required? Why is API level 10 the minimum required?
================================================================================ ================================================================================
@ -446,7 +399,7 @@ https://developer.nvidia.com/tegra-graphics-debugger
API level 10 is the minimum required level at runtime (that is, on the device) API level 10 is the minimum required level at runtime (that is, on the device)
because SDL requires some functionality for running not because SDL requires some functionality for running not
available on older devices. Since the incorporation of joystick support into SDL, available on older devices. Since the incorporation of joystick support into SDL,
the minimum SDK required to *build* SDL is version 12. Devices running API levels the minimum SDK required to *build* SDL is version 16. Devices running API levels
10-11 are still supported, only with the joystick functionality disabled. 10-11 are still supported, only with the joystick functionality disabled.
Support for native OpenGL ES and ES2 applications was introduced in the NDK for Support for native OpenGL ES and ES2 applications was introduced in the NDK for
@ -457,6 +410,7 @@ As of this writing, according to https://developer.android.com/about/dashboards/
about 90% of the Android devices accessing Google Play support API level 10 or about 90% of the Android devices accessing Google Play support API level 10 or
higher (March 2013). higher (March 2013).
================================================================================ ================================================================================
A note regarding the use of the "dirty rectangles" rendering technique A note regarding the use of the "dirty rectangles" rendering technique
================================================================================ ================================================================================
@ -475,6 +429,7 @@ screen each frame.
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
================================================================================ ================================================================================
Known issues Known issues
================================================================================ ================================================================================