Bug 1352015 - Part 1: Fix Android SDK configure checks. r?nalexander draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 06 May 2018 20:39:11 +0200 (2018-05-06)
changeset 792654 7b53dadcefd74168890594f98bd35fee6dcf0709
parent 792653 7db6afe631d5a3acf5ff4c8a30dae3b1a4960cd6
child 792655 aa892246f8377cb35656d0f294c04ebf02d2a7df
push id109173
push usermozilla@buttercookie.de
push dateTue, 08 May 2018 19:37:01 +0000 (2018-05-08)
reviewersnalexander
bugs1352015
milestone62.0a1
Bug 1352015 - Part 1: Fix Android SDK configure checks. r?nalexander It's the *compile*SdkVersion that needs to match the installed Android SDK plat- form in order to be able to build an app, whereas the *target*SdkVersion is merely a compatibility flag. Since the received wisdom is that targetSdkVersion should be <= compileSdk- Version and Android Studio is also showing a warning to that effect if you modify the build.gradle of a small sample app accordingly, I've also added a corresponding configure check of our own to enforce this. MozReview-Commit-ID: F2RZemChFrm
build/autoconf/android.m4
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -112,24 +112,29 @@ case "$target" in
 
     # We were given an old-style
     # --with-android-sdk=/path/to/sdk/platforms/android-*.  We could warn, but
     # we'll get compliance by forcing the issue.
     if test -e "$withval"/source.properties ; then
         AC_MSG_ERROR([Including platforms/android-* in --with-android-sdk arguments is deprecated.  Use --with-android-sdk=$android_sdk_root.])
     fi
 
-    android_target_sdk=$2
-    AC_MSG_CHECKING([for Android SDK platform version $android_target_sdk])
-    android_sdk=$android_sdk_root/platforms/android-$android_target_sdk
+    android_compile_sdk=$1
+    AC_MSG_CHECKING([for Android SDK platform version $android_compile_sdk])
+    android_sdk=$android_sdk_root/platforms/android-$android_compile_sdk
     if ! test -e "$android_sdk/source.properties" ; then
-        AC_MSG_ERROR([You must download Android SDK platform version $android_target_sdk.  Try |mach bootstrap|.  (Looked for $android_sdk)])
+        AC_MSG_ERROR([You must download Android SDK platform version $android_compile_sdk.  Try |mach bootstrap|.  (Looked for $android_sdk)])
     fi
     AC_MSG_RESULT([$android_sdk])
 
+    android_target_sdk=$2
+    if test $android_compile_sdk -lt $android_target_sdk ; then
+        AC_MSG_ERROR([Android compileSdkVersion ($android_compile_sdk) should not be smaller than targetSdkVersion ($android_target_sdk).])
+    fi
+
     AC_MSG_CHECKING([for Android build-tools])
     android_build_tools_base="$android_sdk_root"/build-tools
     android_build_tools_version=""
     for version in $3; do
         android_build_tools="$android_build_tools_base"/$version
         if test -d "$android_build_tools" -a -f "$android_build_tools/aapt"; then
             android_build_tools_version=$version
             AC_MSG_RESULT([$android_build_tools])
@@ -170,19 +175,17 @@ case "$target" in
     dnl Android Tools 26 changes emulator path.
     dnl Although android_sdk_root/tools still has emulator command,
     dnl it doesn't work correctly
     MOZ_PATH_PROG(EMULATOR, emulator, :, [$android_sdk_root/emulator:$android_tools])
     if test -z "$EMULATOR" -o "$EMULATOR" = ":"; then
         AC_MSG_ERROR([The program emulator was not found.  Try |mach bootstrap|.])
     fi
 
-    # `compileSdkVersion ANDROID_COMPILE_SDK_VERSION` is Gradle-only,
-    # so there's no associated configure check.
-    ANDROID_COMPILE_SDK_VERSION=$1
+    ANDROID_COMPILE_SDK_VERSION="${android_compile_sdk}"
     ANDROID_TARGET_SDK="${android_target_sdk}"
     ANDROID_SDK="${android_sdk}"
     ANDROID_SDK_ROOT="${android_sdk_root}"
     ANDROID_TOOLS="${android_tools}"
     ANDROID_BUILD_TOOLS_VERSION="$android_build_tools_version"
     AC_SUBST(ANDROID_COMPILE_SDK_VERSION)
     AC_SUBST(ANDROID_TARGET_SDK)
     AC_SUBST(ANDROID_SDK_ROOT)