Updated Android build tools version, which bumped minimum deployment target to API 14
authorSam Lantinga <slouken@libsdl.org>
Mon, 23 Oct 2017 23:23:47 -0700
changeset 11649fe6769530709
parent 11648 ed5bc0abae1b
child 11650 e7ea7ca30199
Updated Android build tools version, which bumped minimum deployment target to API 14
Also added native code to the Android gradle project, which allows using gradle or Android Studio to build the entire SDL application without a separate ndk-build step.
android-project/app/build.gradle
android-project/app/jni/Application.mk
build-scripts/androidbuild.sh
docs/README-android.md
     1.1 --- a/android-project/app/build.gradle	Mon Oct 23 23:23:34 2017 -0700
     1.2 +++ b/android-project/app/build.gradle	Mon Oct 23 23:23:47 2017 -0700
     1.3 @@ -1,14 +1,19 @@
     1.4  apply plugin: 'com.android.application'
     1.5  
     1.6  android {
     1.7 -    compileSdkVersion 25
     1.8 -    buildToolsVersion "25.0.1"
     1.9 +    compileSdkVersion 16
    1.10 +    buildToolsVersion "26.0.1"
    1.11      defaultConfig {
    1.12          applicationId "org.libsdl.app"
    1.13 -        minSdkVersion 10
    1.14 +        minSdkVersion 14
    1.15          targetSdkVersion 16
    1.16          versionCode 1
    1.17          versionName "1.0"
    1.18 +        externalNativeBuild {
    1.19 +            ndkBuild {
    1.20 +                arguments "APP_PLATFORM=android-14"
    1.21 +            }
    1.22 +        }
    1.23          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    1.24      }
    1.25      buildTypes {
    1.26 @@ -19,7 +24,11 @@
    1.27      }
    1.28      sourceSets.main {
    1.29          jniLibs.srcDir 'libs'
    1.30 -        jni.srcDirs = [] //disable automatic ndk-build call
    1.31 +    }
    1.32 +    externalNativeBuild {
    1.33 +        ndkBuild {
    1.34 +            path 'jni/Android.mk'
    1.35 +        }
    1.36      }
    1.37      lintOptions {
    1.38          abortOnError false
    1.39 @@ -27,7 +36,7 @@
    1.40  }
    1.41  
    1.42  dependencies {
    1.43 -    compile fileTree(dir: 'libs', include: ['*.jar'])
    1.44 +    compile fileTree(include: ['*.jar'], dir: 'libs')
    1.45      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    1.46          exclude group: 'com.android.support', module: 'support-annotations'
    1.47      })
     2.1 --- a/android-project/app/jni/Application.mk	Mon Oct 23 23:23:34 2017 -0700
     2.2 +++ b/android-project/app/jni/Application.mk	Mon Oct 23 23:23:47 2017 -0700
     2.3 @@ -6,4 +6,4 @@
     2.4  APP_ABI := all
     2.5  
     2.6  # Min SDK level
     2.7 -APP_PLATFORM=android-10
     2.8 +APP_PLATFORM=android-14
     3.1 --- a/build-scripts/androidbuild.sh	Mon Oct 23 23:23:34 2017 -0700
     3.2 +++ b/build-scripts/androidbuild.sh	Mon Oct 23 23:23:47 2017 -0700
     3.3 @@ -25,12 +25,9 @@
     3.4      echo "Usage: androidbuild.sh com.yourcompany.yourapp < sources.list"
     3.5      echo "Usage: androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c"
     3.6      echo "To copy SDL source instead of symlinking: COPYSOURCE=1 androidbuild.sh ... "
     3.7 -    echo "You can pass additional arguments to ndk-build with the NDKARGS variable: NDKARGS=\"-s\" androidbuild.sh ..."
     3.8      exit 1
     3.9  fi
    3.10  
    3.11 -
    3.12 -
    3.13  SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
    3.14  
    3.15  if [ -z "$ANDROID_HOME" ];then
    3.16 @@ -38,34 +35,11 @@
    3.17      exit 1
    3.18  fi
    3.19  
    3.20 -NDKBUILD=`which ndk-build`
    3.21 -if [ -z "$NDKBUILD" ];then
    3.22 -    echo "Could not find the ndk-build utility, install Android's NDK and add it to the path"
    3.23 +if [ ! -d "$ANDROID_HOME/ndk-bundle" -a -z "$ANDROID_NDK_HOME" ]; then
    3.24 +    echo "Please set the ANDROID_NDK_HOME directory to the path of the Android NDK"
    3.25      exit 1
    3.26  fi
    3.27  
    3.28 -ANDROID="$ANDROID_HOME/tools/android"
    3.29 -if [ ! -f "$ANDROID" ]; then
    3.30 -    ANDROID=`which android`
    3.31 -fi
    3.32 -if [ -z "$ANDROID" ];then
    3.33 -    echo "Could not find the android utility, install Android's SDK and add it to the path"
    3.34 -    exit 1
    3.35 -fi
    3.36 -
    3.37 -NCPUS="1"
    3.38 -case "$OSTYPE" in
    3.39 -    darwin*)
    3.40 -        NCPU=`sysctl -n hw.ncpu`
    3.41 -        ;; 
    3.42 -    linux*)
    3.43 -        if [ -n `which nproc` ]; then
    3.44 -            NCPUS=`nproc`
    3.45 -        fi  
    3.46 -        ;;
    3.47 -  *);;
    3.48 -esac
    3.49 -
    3.50  APP="$1"
    3.51  APPARR=(${APP//./ })
    3.52  BUILDPATH="$SDLPATH/build/$APP"
    3.53 @@ -121,24 +95,6 @@
    3.54  __EOF__
    3.55  
    3.56  # Update project and build
    3.57 -cd $BUILDPATH
    3.58 -pushd $BUILDPATH/app/jni
    3.59 -$NDKBUILD -j $NCPUS $NDKARGS
    3.60 -popd
    3.61 -
    3.62 -# Start gradle build
    3.63 -$BUILDPATH/gradlew build
    3.64 -
    3.65 -cd $CURDIR
    3.66 -
    3.67 -APK="$BUILDPATH/app/build/outputs/apk/app-debug.apk"
    3.68 -
    3.69 -if [ -f "$APK" ]; then
    3.70 -    echo "Your APK is ready at $APK"
    3.71 -    echo "To install to your device: "
    3.72 -    echo "$ANDROID_HOME/platform-tools/adb install -r $APK"
    3.73 -    exit 0
    3.74 -fi
    3.75 -
    3.76 -echo "There was an error building the APK"
    3.77 -exit 1
    3.78 +echo "To build and install to a device for testing, run the following:"
    3.79 +echo "cd $BUILDPATH"
    3.80 +echo "./gradlew installDebug"
     4.1 --- a/docs/README-android.md	Mon Oct 23 23:23:34 2017 -0700
     4.2 +++ b/docs/README-android.md	Mon Oct 23 23:23:47 2017 -0700
     4.3 @@ -14,11 +14,10 @@
     4.4  Android SDK (version 16 or later)
     4.5  https://developer.android.com/sdk/index.html
     4.6  
     4.7 -Android NDK r7 or later
     4.8 +Android NDK r10e or later
     4.9  https://developer.android.com/tools/sdk/ndk/index.html
    4.10  
    4.11 -Minimum API level supported by SDL: 10 (Android 2.3.3)
    4.12 -Joystick support is available for API level >= 12 devices.
    4.13 +Minimum API level supported by SDL: 14 (Android 4.0.1)
    4.14  
    4.15  
    4.16  ================================================================================
    4.17 @@ -393,22 +392,13 @@
    4.18  
    4.19  
    4.20  ================================================================================
    4.21 - Why is API level 10 the minimum required?
    4.22 + Why is API level 14 the minimum required?
    4.23  ================================================================================
    4.24  
    4.25 -API level 10 is the minimum required level at runtime (that is, on the device) 
    4.26 -because SDL requires some functionality for running not
    4.27 -available on older devices. Since the incorporation of joystick support into SDL,
    4.28 -the minimum SDK required to *build* SDL is version 16. Devices running API levels
    4.29 -10-11 are still supported, only with the joystick functionality disabled.
    4.30 -
    4.31 -Support for native OpenGL ES and ES2 applications was introduced in the NDK for
    4.32 -API level 4 and 8. EGL was made a stable API in the NDK for API level 9, which
    4.33 -has since then been obsoleted, with the recommendation to developers to bump the
    4.34 -required API level to 10.
    4.35 +The latest NDK toolchain doesn't support targeting earlier than API level 14.
    4.36  As of this writing, according to https://developer.android.com/about/dashboards/index.html
    4.37 -about 90% of the Android devices accessing Google Play support API level 10 or
    4.38 -higher (March 2013).
    4.39 +about 99% of the Android devices accessing Google Play support API level 14 or
    4.40 +higher (October 2017).
    4.41  
    4.42  
    4.43  ================================================================================