diff -r 381449ca1cd2 android-project/AndroidManifest.xml
--- a/android-project/AndroidManifest.xml Wed Aug 30 00:40:06 2017 -0700
+++ b/android-project/AndroidManifest.xml Wed Aug 30 21:58:09 2017 +0200
@@ -8,9 +8,6 @@
android:versionName="1.0"
android:installLocation="auto">
-
-
-
diff -r 381449ca1cd2 android-project/ant.properties
--- a/android-project/ant.properties Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 381449ca1cd2 android-project/build.gradle
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/android-project/build.gradle Wed Aug 30 21:58:09 2017 +0200
@@ -0,0 +1,114 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ mavenLocal()
+ jcenter()
+ }
+ dependencies {
+ // https://developer.android.com/studio/releases/gradle-plugin.html#revisions
+ classpath 'com.android.tools.build:gradle:2.2.0'
+ }
+}
+
+allprojects {
+ repositories {
+ mavenLocal()
+ jcenter()
+ }
+
+ gradle.projectsEvaluated {
+ tasks.withType(JavaCompile) {
+ // Enable some warning when compiling the java files
+ // options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
+ }
+ }
+}
+
+apply plugin: 'com.android.application'
+
+android {
+
+ // https://stackoverflow.com/questions/26694108/what-is-the-difference-between-compilesdkversion-and-targetsdkversion
+ // https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd
+ // https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
+ // minSdkVersion (lowest possible) <= targetSdkVersion == compileSdkVersion (latest SDK)
+
+ // This is the SDK version you compile against
+ compileSdkVersion 16
+
+ // https://developer.android.com/studio/releases/build-tools.html
+ buildToolsVersion "26.0.1"
+
+ sourceSets {
+ main {
+ jniLibs.srcDirs = ['libs']
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+ }
+
+ defaultConfig {
+ applicationId 'TEMPLATE_APP_NAME'
+
+
+ // This is the minimal device where the application is allowed to be installed
+ minSdkVersion 10
+
+ // targetSdkVersion is the main way Android provides forward compatibility
+ targetSdkVersion 16
+ }
+
+ signingConfigs {
+ release {
+ storeFile file("/home/me/mykey.keystore")
+ storePassword "mypassword"
+ keyAlias "myalias"
+ keyPassword "mypassword"
+ }
+ }
+
+ externalNativeBuild {
+ ndkBuild {
+ path "jni/Android.mk"
+ }
+ }
+
+ defaultConfig {
+ externalNativeBuild {
+ ndkBuild {
+ arguments "-jTEMPLATE_NCPUS"
+// abiFilters "armeabi"
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+// seem to harm SDL test apps, though it works on real app
+// minifyEnabled true
+ proguardFile getDefaultProguardFile('proguard-android.txt')
+ proguardFile file('./proguard.pro')
+ signingConfig signingConfigs.release
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+}
+
+task appStart(type: Exec) {
+ description 'Run APK on the device'
+ commandLine('adb', 'shell', 'am', 'start', '-n', sprintf("%s/.TEMPLATE_ACTIVITY_NAME", android.defaultConfig.applicationId))
+}
+
+
+// You can use gradle from android-studio: https://developer.android.com/studio/index.html
+// or download it from Gradle: http://services.gradle.org/distributions/
+// (download the bin, and do: ~/Downloads/gradle/gradle-3.2/bin/gradle wrapper)
+task wrapper(type: Wrapper) {
+ gradleVersion = '3.2'
+}
+
diff -r 381449ca1cd2 android-project/build.properties
--- a/android-project/build.properties Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 381449ca1cd2 android-project/build.xml
--- a/android-project/build.xml Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r 381449ca1cd2 android-project/default.properties
--- a/android-project/default.properties Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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-12
diff -r 381449ca1cd2 android-project/proguard-project.txt
--- a/android-project/proguard-project.txt Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-# 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.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff -r 381449ca1cd2 android-project/proguard.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/android-project/proguard.pro Wed Aug 30 21:58:09 2017 +0200
@@ -0,0 +1,20 @@
+# 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.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff -r 381449ca1cd2 android-project/project.properties
--- a/android-project/project.properties Wed Aug 30 00:40:06 2017 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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-12
diff -r 381449ca1cd2 build-scripts/androidbuild.sh
--- a/build-scripts/androidbuild.sh Wed Aug 30 00:40:06 2017 -0700
+++ b/build-scripts/androidbuild.sh Wed Aug 30 21:58:09 2017 +0200
@@ -39,16 +39,16 @@
exit 1
fi
-ANDROID=`which android`
-if [ -z "$ANDROID" ];then
- echo "Could not find the android utility, install Android's SDK and add it to the path"
+if [ -z "$ANDROID_HOME" ];then
+ echo "Could not find environment variable ANDROID_HOME. Set it to your Android's SDK location."
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"
+# you can get gradle from Android Studio (android-studio/gradle/gradle-3.2/bin/)
+# or from http://services.gradle.org/distributions/
+GRADLE=`which gradle`
+if [ -z "$GRADLE" ];then
+ echo "Could not find the gradle utility, install Android Studio and add gradle to you PATH"
exit 1
fi
@@ -106,30 +106,46 @@
ACTIVITY="${folder}Activity"
sed -i -e "s|SDLActivity|$ACTIVITY|g" $BUILDPATH/AndroidManifest.xml
-sed -i -e "s|SDLActivity|$APP|g" $BUILDPATH/build.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"
-# Update project and build
+# Update the gradle file
+sed -i -e "s|TEMPLATE_ACTIVITY_NAME|$ACTIVITY|g" $BUILDPATH/build.gradle
+sed -i -e "s|TEMPLATE_APP_NAME|$APP|g" $BUILDPATH/build.gradle
+sed -i -e "s|TEMPLATE_NCPUS|$NCPUS|g" $BUILDPATH/build.gradle
+
+
+# Build project in debug.
+# To build in release, you need to sign it
cd $BUILDPATH
-$ANDROID update project --path $BUILDPATH
-$NDKBUILD -j $NCPUS $NDKARGS
-$ANT debug
+
+# $GRADLE assembleRelease
+$GRADLE assembleDebug
cd $CURDIR
-APK="$BUILDPATH/bin/$APP-debug.apk"
-
-if [ -f "$APK" ]; then
- echo "Your APK is ready at $APK"
+APK_RELEASE="$BUILDPATH/build/outputs/apk/$APP-release.apk"
+if [ -f "$APK_RELEASE" ]; then
+ echo "Your release APK is ready at $APK"
echo "To install to your device: "
echo "cd $BUILDPATH"
- echo "ant debug install"
+ echo "gradle installRelease"
+ echo "gradle appStart"
+ exit 0
+fi
+
+APK_DEBUG="$BUILDPATH/build/outputs/apk/$APP-debug.apk"
+if [ -f "$APK_DEBUG" ]; then
+ echo "Your debug APK is ready at $APK"
+ echo "To install to your device: "
+ echo "cd $BUILDPATH"
+ echo "gradle installDebug"
+ echo "gradle appStart"
exit 0
fi
echo "There was an error building the APK"
-exit 1
\ No newline at end of file
+exit 1