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
--- 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)