diff --git a/android-project/ant.properties b/android-project/ant.properties
deleted file mode 100644
index b0971e891..000000000
--- a/android-project/ant.properties
+++ /dev/null
@@ -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.
-
diff --git a/android-project/app/app.iml b/android-project/app/app.iml
new file mode 100644
index 000000000..d7d367daa
--- /dev/null
+++ b/android-project/app/app.iml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-project/app/build.gradle b/android-project/app/build.gradle
new file mode 100644
index 000000000..b670a69c8
--- /dev/null
+++ b/android-project/app/build.gradle
@@ -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'
+}
diff --git a/android-project/jni/Android.mk b/android-project/app/jni/Android.mk
similarity index 100%
rename from android-project/jni/Android.mk
rename to android-project/app/jni/Android.mk
diff --git a/android-project/jni/Application.mk b/android-project/app/jni/Application.mk
similarity index 72%
rename from android-project/jni/Application.mk
rename to android-project/app/jni/Application.mk
index 5ea0fb4ce..70bcf0c24 100644
--- a/android-project/jni/Application.mk
+++ b/android-project/app/jni/Application.mk
@@ -1,10 +1,9 @@
# Uncomment this if you're using STL in your project
# 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
APP_PLATFORM=android-10
-
diff --git a/android-project/jni/src/Android.mk b/android-project/app/jni/src/Android.mk
similarity index 100%
rename from android-project/jni/src/Android.mk
rename to android-project/app/jni/src/Android.mk
diff --git a/android-project/proguard-project.txt b/android-project/app/proguard-rules.pro
similarity index 62%
rename from android-project/proguard-project.txt
rename to android-project/app/proguard-rules.pro
index f2fe1559a..eaf0e916c 100644
--- a/android-project/proguard-project.txt
+++ b/android-project/app/proguard-rules.pro
@@ -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.
# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
+# in [sdk]/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
diff --git a/android-project/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml
similarity index 69%
rename from android-project/AndroidManifest.xml
rename to android-project/app/src/main/AndroidManifest.xml
index 3845127e9..cd7f52091 100644
--- a/android-project/AndroidManifest.xml
+++ b/android-project/app/src/main/AndroidManifest.xml
@@ -1,15 +1,15 @@
-
+ package="org.libsdl.app"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:installLocation="auto">
-
+
@@ -23,23 +23,22 @@
+ android:icon="@mipmap/ic_launcher"
+ android:allowBackup="true"
+ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+ android:hardwareAccelerated="true" >
+ android:label="@string/app_name"
+ android:configChanges="keyboardHidden|orientation|screenSize"
+ >
@@ -55,4 +54,4 @@
-
+
diff --git a/android-project/src/org/libsdl/app/SDL.java b/android-project/app/src/main/java/org/libsdl/app/SDL.java
similarity index 100%
rename from android-project/src/org/libsdl/app/SDL.java
rename to android-project/app/src/main/java/org/libsdl/app/SDL.java
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
similarity index 99%
rename from android-project/src/org/libsdl/app/SDLActivity.java
rename to android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 9119473f5..ae958b0e2 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -36,7 +36,7 @@ public class SDLActivity extends Activity {
// Handle the state of the native layer
public enum NativeState {
- INIT, RESUMED, PAUSED
+ INIT, RESUMED, PAUSED
}
public static NativeState mNextNativeState;
@@ -208,7 +208,7 @@ public class SDLActivity extends Activity {
mLayout.addView(mSurface);
setContentView(mLayout);
-
+
// Get filename from "Open with" of another application
Intent intent = getIntent();
if (intent != null && intent.getData() != null) {
@@ -265,7 +265,7 @@ public class SDLActivity extends Activity {
} else {
mNextNativeState = NativeState.PAUSED;
}
-
+
SDLActivity.handleNativeState();
}
@@ -542,7 +542,7 @@ public class SDLActivity extends Activity {
{
int orientation = -1;
- if (!Objects.equals(hint, "")) {
+ if (hint != "") {
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
} else if (hint.contains("LandscapeRight")) {
@@ -1152,7 +1152,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate());
Log.v("SDL", "Window size: " + width + "x" + height);
-
+
boolean skip = false;
int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();
@@ -1175,7 +1175,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
if (skip) {
double min = Math.min(mWidth, mHeight);
double max = Math.max(mWidth, mHeight);
-
+
if (max / min < 1.20) {
Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution.");
skip = false;
@@ -1187,7 +1187,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
SDLActivity.mIsSurfaceReady = false;
return;
}
-
+
/* Surface is ready */
SDLActivity.mIsSurfaceReady = true;
diff --git a/android-project/src/org/libsdl/app/SDLAudioManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java
similarity index 100%
rename from android-project/src/org/libsdl/app/SDLAudioManager.java
rename to android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java
diff --git a/android-project/src/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
similarity index 99%
rename from android-project/src/org/libsdl/app/SDLControllerManager.java
rename to android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
index 36294422f..63128aaa4 100644
--- a/android-project/src/org/libsdl/app/SDLControllerManager.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
@@ -266,7 +266,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
public String getJoystickDescriptor(InputDevice joystickDevice) {
String desc = joystickDevice.getDescriptor();
- if (desc != null && !Objects.equals(desc, "")) {
+ if (desc != null && desc != "") {
return desc;
}
diff --git a/android-project/res/drawable-hdpi/ic_launcher.png b/android-project/app/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from android-project/res/drawable-hdpi/ic_launcher.png
rename to android-project/app/src/main/res/mipmap-hdpi/ic_launcher.png
diff --git a/android-project/res/drawable-mdpi/ic_launcher.png b/android-project/app/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from android-project/res/drawable-mdpi/ic_launcher.png
rename to android-project/app/src/main/res/mipmap-mdpi/ic_launcher.png
diff --git a/android-project/res/drawable-xhdpi/ic_launcher.png b/android-project/app/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from android-project/res/drawable-xhdpi/ic_launcher.png
rename to android-project/app/src/main/res/mipmap-xhdpi/ic_launcher.png
diff --git a/android-project/res/drawable-xxhdpi/ic_launcher.png b/android-project/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from android-project/res/drawable-xxhdpi/ic_launcher.png
rename to android-project/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/android-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 000000000..959c384b0
Binary files /dev/null and b/android-project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/android-project/app/src/main/res/values/colors.xml b/android-project/app/src/main/res/values/colors.xml
new file mode 100644
index 000000000..3ab3e9cbc
--- /dev/null
+++ b/android-project/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/android-project/app/src/main/res/values/strings.xml b/android-project/app/src/main/res/values/strings.xml
new file mode 100644
index 000000000..ab7953306
--- /dev/null
+++ b/android-project/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Game
+
diff --git a/android-project/app/src/main/res/values/styles.xml b/android-project/app/src/main/res/values/styles.xml
new file mode 100644
index 000000000..ff6c9d2c0
--- /dev/null
+++ b/android-project/app/src/main/res/values/styles.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/android-project/build.gradle b/android-project/build.gradle
new file mode 100644
index 000000000..c2eea8e27
--- /dev/null
+++ b/android-project/build.gradle
@@ -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
+}
diff --git a/android-project/build.properties b/android-project/build.properties
deleted file mode 100644
index edc7f2305..000000000
--- a/android-project/build.properties
+++ /dev/null
@@ -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.
-
diff --git a/android-project/build.xml b/android-project/build.xml
deleted file mode 100644
index 9f19a077b..000000000
--- a/android-project/build.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android-project/default.properties b/android-project/default.properties
deleted file mode 100644
index 0a69b7743..000000000
--- a/android-project/default.properties
+++ /dev/null
@@ -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
diff --git a/android-project/gradle.properties b/android-project/gradle.properties
new file mode 100644
index 000000000..aac7c9b46
--- /dev/null
+++ b/android-project/gradle.properties
@@ -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
diff --git a/android-project/gradle/wrapper/gradle-wrapper.jar b/android-project/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..13372aef5
Binary files /dev/null and b/android-project/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android-project/gradle/wrapper/gradle-wrapper.properties b/android-project/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..6035d0e12
--- /dev/null
+++ b/android-project/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/android-project/gradlew b/android-project/gradlew
new file mode 100755
index 000000000..9d82f7891
--- /dev/null
+++ b/android-project/gradlew
@@ -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 "$@"
diff --git a/android-project/gradlew.bat b/android-project/gradlew.bat
new file mode 100644
index 000000000..aec99730b
--- /dev/null
+++ b/android-project/gradlew.bat
@@ -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
diff --git a/android-project/jni/src/Android_static.mk b/android-project/jni/src/Android_static.mk
deleted file mode 100644
index faed669c0..000000000
--- a/android-project/jni/src/Android_static.mk
+++ /dev/null
@@ -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)
diff --git a/android-project/project.properties b/android-project/project.properties
deleted file mode 100644
index 9b84a6b4b..000000000
--- a/android-project/project.properties
+++ /dev/null
@@ -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
diff --git a/android-project/res/layout/main.xml b/android-project/res/layout/main.xml
deleted file mode 100644
index 123c4b6ea..000000000
--- a/android-project/res/layout/main.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
diff --git a/android-project/res/values/strings.xml b/android-project/res/values/strings.xml
deleted file mode 100644
index 9bce51cb3..000000000
--- a/android-project/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- SDL App
-
diff --git a/android-project/settings.gradle b/android-project/settings.gradle
new file mode 100644
index 000000000..e7b4def49
--- /dev/null
+++ b/android-project/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/build-scripts/androidbuild.sh b/build-scripts/androidbuild.sh
index fb48e2e5b..916831cce 100755
--- a/build-scripts/androidbuild.sh
+++ b/build-scripts/androidbuild.sh
@@ -33,25 +33,26 @@ fi
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`
if [ -z "$NDKBUILD" ];then
echo "Could not find the ndk-build utility, install Android's NDK and add it to the path"
exit 1
fi
-ANDROID=`which android`
+ANDROID="$ANDROID_HOME/tools/android"
+if [ ! -f "$ANDROID" ]; then
+ ANDROID=`which android`
+fi
if [ -z "$ANDROID" ];then
echo "Could not find the android utility, install Android's SDK and add it to the path"
exit 1
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"
case "$OSTYPE" in
darwin*)
@@ -77,27 +78,28 @@ mkdir -p $BUILDPATH
cp -r $SDLPATH/android-project/* $BUILDPATH
# Copy SDL sources
-mkdir -p $BUILDPATH/jni/SDL
+mkdir -p $BUILDPATH/app/jni/SDL
if [ -z "$COPYSOURCE" ]; then
- ln -s $SDLPATH/src $BUILDPATH/jni/SDL
- ln -s $SDLPATH/include $BUILDPATH/jni/SDL
+ ln -s $SDLPATH/src $BUILDPATH/app/jni/SDL
+ ln -s $SDLPATH/include $BUILDPATH/app/jni/SDL
else
- cp -r $SDLPATH/src $BUILDPATH/jni/SDL
- cp -r $SDLPATH/include $BUILDPATH/jni/SDL
+ cp -r $SDLPATH/src $BUILDPATH/app/jni/SDL
+ cp -r $SDLPATH/include $BUILDPATH/app/jni/SDL
fi
-cp -r $SDLPATH/Android.mk $BUILDPATH/jni/SDL
-sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/jni/src/Android.mk
-sed -i -e "s|org\.libsdl\.app|$APP|g" $BUILDPATH/AndroidManifest.xml
+cp -r $SDLPATH/Android.mk $BUILDPATH/app/jni/SDL
+sed -i -e "s|YourSourceHere.c|$MKSOURCES|g" $BUILDPATH/app/jni/src/Android.mk
+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
for src in "${SOURCES[@]}"
do
- cp $src $BUILDPATH/jni/src
+ cp $src $BUILDPATH/app/jni/src
done
# Create an inherited Activity
-cd $BUILDPATH/src
+cd $BUILDPATH/app/src/main/java
for folder in "${APPARR[@]}"
do
mkdir -p $folder
@@ -105,31 +107,38 @@ do
done
ACTIVITY="${folder}Activity"
-sed -i -e "s|SDLActivity|$ACTIVITY|g" $BUILDPATH/AndroidManifest.xml
-sed -i -e "s|SDLActivity|$APP|g" $BUILDPATH/build.xml
+sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" $BUILDPATH/app/src/main/AndroidManifest.xml
# Fill in a default Activity
-echo "package $APP;" > "$ACTIVITY.java"
-echo "import org.libsdl.app.SDLActivity;" >> "$ACTIVITY.java"
-echo "public class $ACTIVITY extends SDLActivity {}" >> "$ACTIVITY.java"
+cat >"$ACTIVITY.java" <<__EOF__
+package $APP;
+
+import org.libsdl.app.SDLActivity;
+
+public class $ACTIVITY extends SDLActivity
+{
+}
+__EOF__
# Update project and build
cd $BUILDPATH
-$ANDROID update project --path $BUILDPATH
+pushd $BUILDPATH/app/jni
$NDKBUILD -j $NCPUS $NDKARGS
-$ANT debug
+popd
+
+# Start gradle build
+$BUILDPATH/gradlew build
cd $CURDIR
-APK="$BUILDPATH/bin/$APP-debug.apk"
+APK="$BUILDPATH/app/build/outputs/apk/app-debug.apk"
if [ -f "$APK" ]; then
echo "Your APK is ready at $APK"
echo "To install to your device: "
- echo "cd $BUILDPATH"
- echo "ant debug install"
+ echo "$ANDROID_HOME/platform-tools/adb install -r $APK"
exit 0
fi
echo "There was an error building the APK"
-exit 1
\ No newline at end of file
+exit 1
diff --git a/docs/README-android.md b/docs/README-android.md
index 747bf72d9..1bf4dfd9f 100644
--- a/docs/README-android.md
+++ b/docs/README-android.md
@@ -4,7 +4,8 @@ Android
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
-The rest of this README covers the old style build process.
+The rest of this README covers the traditional style build process.
+
================================================================================
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)
Joystick support is available for API level >= 12 devices.
+
================================================================================
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
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
dispatches to native functions implemented in the SDL library:
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
@@ -74,71 +73,32 @@ For more complex projects, follow these instructions:
1. Copy the android-project directory wherever you want to keep your projects
and rename it to the name of your project.
-2. Move or symlink this SDL directory into the "/jni" directory
-3. Edit "/jni/src/Android.mk" to include your source files
+2. Move or symlink this SDL directory into the "/app/jni" directory
+3. Edit "/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
-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 "/local.properties" and use that to point to the Android SDK directory, by writing a line with the following form:
-
- 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)
+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
Here's an explanation of the files in the Android project, so you can customize them:
- android-project/
- AndroidManifest.xml - package manifest. Among others, it contains the class name
+ android-project/app
+ 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.
- 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/Android.mk - Android makefile that can call recursively the Android.mk files
- in all subdirectories
+ jni/Application.mk - Application JNI settings, including target platform and STL library
+ 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/Android.mk - Android makefile for creating the SDL shared library
jni/src/ - directory holding your C/C++ 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. Could be
- one dir called "drawable".
- res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout.
- 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 "/jni/src/Android_static.mk" to "/jni/src/Android.mk"
- (overwrite the existing one)
-3. Edit "/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 "/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
+ jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
+ src/main/assets/ - directory holding asset files for your application
+ src/main/res/ - directory holding resources for your application
+ src/main/res/mipmap-* - directories holding icons for different phone hardware
+ src/main/res/values/strings.xml - strings used in your application, including the application name
+ 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.
================================================================================
@@ -171,25 +131,23 @@ Here's an example of a minimal class file:
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
class, .e.g. "MyGame"
+
================================================================================
Customizing your application icon
================================================================================
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
-different screen sizes. These can be replaced with one dir called "drawable",
-containing an icon file "ic_launcher.png" with dimensions 48x48 or 72x72.
+the drawable directories under the res directory. There are several directories
+for different screen sizes.
-You may need to change the name of your icon in AndroidManifest.xml to match
-this icon filename.
================================================================================
Loading assets
================================================================================
-Any files you put in the "assets" directory of your android-project directory
-will get bundled into the application package and you can load them using the
-standard functions in SDL_rwops.h.
+Any files you put in the "app/src/main/assets" directory of your project
+directory will get bundled into the application package and you can load
+them using the standard functions in SDL_rwops.h.
There are also a few Android specific functions that allow you to get other
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/
+
================================================================================
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
under iOS, if the OS can not restore your GL context it will just kill your app)
+
================================================================================
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
detach it.
+
================================================================================
Using STL
================================================================================
@@ -257,6 +218,7 @@ folder and adding the following line:
For more information check out CPLUSPLUS-SUPPORT.html in the NDK 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:
- 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
+You can open your project directory with Android Studio and run it normally.
================================================================================
@@ -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.
Using a real device works better.
+
================================================================================
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:
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 ""
+
================================================================================
Graphics debugging
================================================================================
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
-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.
The Tegra Graphics Debugger is available from NVidia here:
https://developer.nvidia.com/tegra-graphics-debugger
+
================================================================================
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)
because SDL requires some functionality for running not
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.
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
higher (March 2013).
+
================================================================================
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
+
================================================================================
Known issues
================================================================================