diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-10 19:14:10 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-03-17 14:25:37 +0100 |
commit | 9544dcc4834bf816e9e75f0aa9937a1562b2353f (patch) | |
tree | d2c2eec9d7b171ccbc5f3a82104dd19f804b8343 /platform | |
parent | aed3869cfaf0f590f58265e203dd7b9a2ee38fb7 (diff) | |
download | qtlocation-mapboxgl-9544dcc4834bf816e9e75f0aa9937a1562b2353f.tar.gz |
[android] move build to Android Studio
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/.gitignore | 5 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/build.gradle | 60 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/gradle.properties | 4 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/README.md | 14 | ||||
-rw-r--r-- | platform/android/bitrise.yml | 41 | ||||
-rw-r--r-- | platform/android/build.gradle | 3 | ||||
-rw-r--r-- | platform/android/config.cmake | 23 | ||||
-rwxr-xr-x | platform/android/scripts/debug.sh | 42 | ||||
-rwxr-xr-x | platform/android/scripts/metrics.sh | 14 | ||||
-rwxr-xr-x | platform/android/scripts/ndk.sh | 123 | ||||
-rw-r--r-- | platform/android/tests/docs/UI_TESTS.md | 4 | ||||
-rw-r--r-- | platform/android/tests/docs/UNIT_TESTS.md | 4 |
12 files changed, 119 insertions, 218 deletions
diff --git a/platform/android/.gitignore b/platform/android/.gitignore index 81eeaad167..7a3db0aafd 100644 --- a/platform/android/.gitignore +++ b/platform/android/.gitignore @@ -7,17 +7,16 @@ # Build files build/ +.externalNativeBuild *.so *.apk -# JNI -MapboxGLAndroidSDK/src/main/jniLibs/ - # Lib assets MapboxGLAndroidSDK/src/main/assets/ # Local settings local.properties +/configuration.gradle # Token file MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 6602d919a3..dd25a8d7b4 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -29,6 +29,66 @@ android { buildConfigField "String", "GIT_REVISION_SHORT", String.format("\"%s\"", getGitRevision()) } + defaultPublishConfig project.hasProperty("mapbox.buildtype") ? project.getProperty("mapbox.buildtype") : "debug" + + // We sometimes want to invoke Gradle without building a native dependency, e.g. when we just want + // to invoke the Java tests. When we explicitly specify an ABI of 'none', no native dependencies are + // added. When another ABI is specified explicitly, we're just going to build that ABI. In all other + // cases, all ABIs are built. + // When invoking from the command line, set `-Pmapbox.abis=...` to only build the desired architectures. + // When building from Android Studio, gradle.properties sets `android.buildOnlyTargetAbi=true` so that + // only the architecture for the device you're running on gets built. + def abi = 'all' + if (!project.hasProperty('android.injected.invoked.from.ide')) { + // Errors when the user invokes Gradle from the command line and didn't set mapbox.abis + abi = project.getProperty("mapbox.abis") + } + + if (abi != 'none') { + externalNativeBuild { + cmake { + path "../../../CMakeLists.txt" + } + } + } + + defaultConfig { + if (abi != 'none') { + externalNativeBuild { + cmake { + arguments "-DANDROID_TOOLCHAIN=clang" + arguments "-DANDROID_STL=c++_static" + arguments "-DANDROID_CPP_FEATURES=rtti;exceptions" + arguments "-DMBGL_PLATFORM=android" + arguments "-DMASON_PLATFORM=android" + arguments "-DNodeJS_EXECUTABLE=" + rootProject.ext.node + arguments "-Dnpm_EXECUTABLE=" + rootProject.ext.npm + + // Enable ccache if the user has installed it. + if (rootProject.ext.ccache?.trim()) { + arguments "-DANDROID_CCACHE=" + rootProject.ext.ccache + // ccache splits up the compile command until multiple invocations and uses -E + // with one of them, and clang doesn't like unused arguments in that case. + cFlags "-Qunused-arguments" + cppFlags "-Qunused-arguments" + } + + targets "mapbox-gl" + targets "example-custom-layer" + if (project.hasProperty("mapbox.with_test")) { + targets "mbgl-test" + } + + if (abi != 'all') { + abiFilters abi.split(' ') + } else { + abiFilters "armeabi", "armeabi-v7a", "mips", "x86", "arm64-v8a", "x86_64" + } + } + } + } + } + // avoid naming conflicts, force usage of prefix resourcePrefix 'mapbox_' diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index dac39fa60a..13a5f1032a 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -14,3 +14,7 @@ POM_DEVELOPER_NAME=Mapbox POM_NAME=Mapbox Android SDK POM_ARTIFACT_ID=mapbox-android-sdk POM_PACKAGING=aar + +# Only build native dependencies for the current ABI +# See https://code.google.com/p/android/issues/detail?id=221098#c20 +android.buildOnlyTargetAbi=true diff --git a/platform/android/MapboxGLAndroidSDKTestApp/README.md b/platform/android/MapboxGLAndroidSDKTestApp/README.md index 0acb509b3e..c7a918cd48 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/README.md +++ b/platform/android/MapboxGLAndroidSDKTestApp/README.md @@ -1,5 +1,15 @@ # Mapbox GL Test App +## Building + +To be able to run any Gradle commands, you'll need to create the configuration file by running + +``` +$ make android-configuration +``` + +from the root folder. + ## Testing ### Running Espresso tests on a device @@ -28,7 +38,7 @@ On a terminal, within `mapbox-gl-native/android/java`, run the tests (`cC` stands for `connectedCheck`): ``` -$ ./gradlew cC -p MapboxGLAndroidSDKTestApp +$ ./gradlew -Pmapbox.abis=all cC -p MapboxGLAndroidSDKTestApp ``` Then: @@ -63,7 +73,7 @@ You can also have a run configuration: You can also run the tests from the command line with: ``` -$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp +$ ./gradlew -Pmapbox.abis=none test -p MapboxGLAndroidSDKTestApp ``` ### Running the UI/Application Exerciser Monkey diff --git a/platform/android/bitrise.yml b/platform/android/bitrise.yml index 0470bccd02..6e1f9a0d19 100644 --- a/platform/android/bitrise.yml +++ b/platform/android/bitrise.yml @@ -14,13 +14,6 @@ workflows: primary: steps: - script: - title: Run Checkstyle - inputs: - - content: |- - #!/bin/bash - # Run checkstyle gradle task on all modules - cd platform/android && ./gradlew checkstyle - - script: title: Configure Google Cloud SDK inputs: - content: |- @@ -45,9 +38,12 @@ workflows: inputs: - content: |- #!/bin/bash + # Accept Android SDK license + echo "Accepting Android SDK license..." + mkdir -p "${ANDROID_HOME}/licenses" + echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" echo "Compile libmapbox-gl.so for armeabi-v7a abi:" - export BUILDTYPE=Debug - make android-lib-arm-v7 + BUILDTYPE=Debug make android-lib-arm-v7 - script: title: Compile Core tests inputs: @@ -77,6 +73,13 @@ workflows: echo "Generate these test locally by executing:" make test-code-android - script: + title: Run Checkstyle + inputs: + - content: |- + #!/bin/bash + # Run checkstyle gradle task on all modules + make android-checkstyle + - script: title: Run Firebase instrumentation tests inputs: - content: |- @@ -85,7 +88,7 @@ workflows: wget -O platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml "$BITRISEIO_TEST_ACCESS_TOKEN_UI_TEST_URL" echo "Build seperate test apk:" - make android-ui-test + make android-ui-test-arm-v7 echo "Run tests on firebase:" gcloud auth activate-service-account --key-file secret.json --project android-gl-native @@ -156,17 +159,20 @@ workflows: inputs: - content: |- #!/bin/bash + # Accept Android SDK license + echo "Accepting Android SDK license..." + mkdir -p "${ANDROID_HOME}/licenses" + echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" echo "Compile libmapbox-gl.so for all supportd abi's:" export BUILDTYPE=Release make apackage - cd platform/android && ./gradlew :MapboxGLAndroidSDK:assembleRelease - script: title: Publish to maven inputs: - content: |- #!/bin/bash echo "Upload aar file to maven:" - cd platform/android && ./gradlew :MapboxGLAndroidSDK:uploadArchives + make run-android-upload-archives - slack: title: Post to Slack inputs: @@ -185,6 +191,10 @@ workflows: inputs: - content: |- #!/bin/bash + # Accept Android SDK license + echo "Accepting Android SDK license..." + mkdir -p "${ANDROID_HOME}/licenses" + echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" echo "Compile libmapbox-gl.so for all supportd abi's:" export BUILDTYPE=Release make apackage @@ -208,7 +218,7 @@ workflows: - content: |- #!/bin/bash echo "Run tests on device farm:" - cd platform/android && ./gradlew devicefarmUpload + make run-android-ui-test-aws - slack: title: Post to Slack inputs: @@ -234,10 +244,13 @@ workflows: inputs: - content: |- #!/bin/bash + # Accept Android SDK license + echo "Accepting Android SDK license..." + mkdir -p "${ANDROID_HOME}/licenses" + echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" echo "Compile libmapbox-gl.so for all supportd abi's:" export BUILDTYPE=Release make apackage - cd platform/android && ./gradlew :MapboxGLAndroidSDK:assembleRelease - script: title: Log metrics inputs: diff --git a/platform/android/build.gradle b/platform/android/build.gradle index 4219f2bdee..5e45232716 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -21,3 +21,6 @@ task wrapper(type: Wrapper) { apply from: rootProject.file('dependencies.gradle') +// Load build system information. If this file does not exist, run +// `make platform/android/configuration.gradle` +apply from: rootProject.file('configuration.gradle') diff --git a/platform/android/config.cmake b/platform/android/config.cmake index fdf03b4ec8..1a68ee065d 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -22,15 +22,6 @@ mason_use(sqlite VERSION 3.14.2) mason_use(gtest VERSION 1.8.0) mason_use(icu VERSION 58.1-min-size) -set(ANDROID_SDK_PROJECT_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDK) -set(ANDROID_JNI_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/jniLibs/${ANDROID_ABI}) -set(ANDROID_ASSETS_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/assets) -set(ANDROID_TEST_APP_JNI_TARGET_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs/${ANDROID_ABI}) - -if (NOT DEFINED ANDROID_TOOLCHAIN_PREFIX) - set(ANDROID_TOOLCHAIN_PREFIX "${MASON_XC_ROOT}/bin/${ANDROID_TOOLCHAIN}-") -endif() - ## mbgl core ## macro(mbgl_platform_core) @@ -251,11 +242,6 @@ target_link_libraries(mapbox-gl PUBLIC -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/version-script ) -# Create a stripped version of the library and copy it to the JNIDIR. -add_custom_command(TARGET mapbox-gl POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_JNI_TARGET_DIR} - COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mapbox-gl> -o ${ANDROID_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:mapbox-gl>) - ## Test library ## add_library(mbgl-test SHARED @@ -312,11 +298,6 @@ target_add_mason_package(mbgl-test PRIVATE boost) target_add_mason_package(mbgl-test PRIVATE geojson) target_add_mason_package(mbgl-test PRIVATE geojsonvt) -add_custom_command(TARGET mbgl-test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/stripped - COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mapbox-gl> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mapbox-gl> - COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:mbgl-test> -o ${CMAKE_CURRENT_BINARY_DIR}/stripped/$<TARGET_FILE_NAME:mbgl-test>) - ## Custom layer example ## add_library(example-custom-layer SHARED @@ -334,7 +315,3 @@ target_link_libraries(example-custom-layer PUBLIC -Wl,--gc-sections PUBLIC -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/version-script ) - -add_custom_command(TARGET example-custom-layer POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_TEST_APP_JNI_TARGET_DIR} - COMMAND ${ANDROID_TOOLCHAIN_PREFIX}strip $<TARGET_FILE:example-custom-layer> -o ${ANDROID_TEST_APP_JNI_TARGET_DIR}/$<TARGET_FILE_NAME:example-custom-layer>) diff --git a/platform/android/scripts/debug.sh b/platform/android/scripts/debug.sh deleted file mode 100755 index 909c47f992..0000000000 --- a/platform/android/scripts/debug.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -# Automation of https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB - -export MASON_ANDROID_ARCH=x86 -export MASON_ANDROID_PLATFORM=9 -export MASON_ANDROID_NDK_VERSION=r14 - -export MASON_XC_ROOT=`scripts/mason.sh PREFIX android-ndk VERSION ${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}-${MASON_ANDROID_NDK_VERSION}` -source ${MASON_XC_ROOT}/toolchain.sh - -if [[ $1 == '--prepare' ]]; then - mkdir -p ~/.android/debugging/{vendor,system}_lib - adb pull /system/lib ~/.android/debugging/system_lib - adb pull /vendor/lib ~/.android/debugging/vendor_lib - adb pull /system/bin/app_process ~/.android/debugging - adb pull /system/bin/app_process32 ~/.android/debugging - adb pull /system/bin/linker ~/.android/debugging - - if [[ ${MASON_ANDROID_ARCH} == 'arm-v8' || ${MASON_ANDROID_ARCH} == 'x86-64' || ${MASON_ANDROID_ARCH} == 'mips-64' ]]; then - adb pull /system/bin/app_process64 ~/.android/debugging - adb pull /system/bin/linker64 ~/.android/debugging - fi - - cp ${MASON_XC_ROOT}/prebuilt/gdbserver/gdbserver \ - platform/android/MapboxGLAndroidSDK/src/main/jniLibs/${ANDROID_ABI}/gdbserver.so -fi - -adb install -r -t -d -g platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk -adb shell am start -n "com.mapbox.mapboxsdk.testapp/com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" \ - -a android.intent.action.MAIN -c android.intent.category.LAUNCHER - -adb forward tcp:5039 tcp:5039 -adb shell run-as com.mapbox.mapboxsdk.testapp '/data/data/com.mapbox.mapboxsdk.testapp/lib/gdbserver.so \ - --attach :5039 `pgrep com.mapbox.mapboxsdk.testapp`' & - -${MASON_XC_ROOT}/bin/gdb \ - -ex "target remote :5039" \ - -ex "set solib-search-path ~/.android/debugging:~/.android/debugging/system_lib:~/.android/debugging/vendor_lib:~/.android/debugging/vendor_lib/egl:./build/android-${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}/Debug/lib.target/" diff --git a/platform/android/scripts/metrics.sh b/platform/android/scripts/metrics.sh index 37d8c1de65..974ee5e8db 100755 --- a/platform/android/scripts/metrics.sh +++ b/platform/android/scripts/metrics.sh @@ -4,12 +4,12 @@ set -e set -o pipefail # Track individual architectures -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/armeabi/libmapbox-gl.so" "Platform=Android,Arch=arm-v5" -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/armeabi-v7a/libmapbox-gl.so" "Platform=Android,Arch=arm-v7" -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/arm64-v8a/libmapbox-gl.so" "Platform=Android,Arch=arm-v8" -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/x86/libmapbox-gl.so" "Platform=Android,Arch=x86" -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/x86_64/libmapbox-gl.so" "Platform=Android,Arch=x86_64" -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/src/main/jniLibs/mips/libmapbox-gl.so" "Platform=Android,Arch=mips" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/armeabi/libmapbox-gl.so" "Platform=Android,Arch=arm-v5" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/armeabi-v7a/libmapbox-gl.so" "Platform=Android,Arch=arm-v7" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/arm64-v8a/libmapbox-gl.so" "Platform=Android,Arch=arm-v8" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/x86/libmapbox-gl.so" "Platform=Android,Arch=x86" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/x86_64/libmapbox-gl.so" "Platform=Android,Arch=x86_64" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/intermediates/bundles/default/jni/mips/libmapbox-gl.so" "Platform=Android,Arch=mips" # Track overall library size -scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Platform=Android,Arch=Archive" +scripts/log_binary_size.sh "platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar" "Platform=Android,Arch=Archive" diff --git a/platform/android/scripts/ndk.sh b/platform/android/scripts/ndk.sh deleted file mode 100755 index 0a858a6daa..0000000000 --- a/platform/android/scripts/ndk.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail -set -u - -# This script produces an env.sh file, which contains the paths to CMake, and the flags required to -# create a build. It first tries to use the Android NDK, but falls back to installing it via Mason. - -function error { >&2 echo -e "\033[1m\033[31m$@\033[0m"; } -function warning { >&2 echo -e "\033[1m\033[33m$@\033[0m"; } -function status { >&2 echo -e "\033[1m\033[36m$@\033[0m"; } -function info { >&2 echo -e "\033[1m\033[32m$@\033[0m"; } - -if [ "$#" -ne 3 ]; then - error "Usage: $0 <short arch> <long arch> <api level>" -fi - -NDK_ANDROID_VERSION=$1-$3 -ANDROID_NATIVE_API_LEVEL=$3 -ANDROID_ABI=$2 - -MASON_NDK_VERSION=r14 - -function is_supported_ndk_version { - [ "$1" = "13.1.3345770" ] || [ "$1" = "14.0.3770861" ] -} - -function mason_ndk { - local CMAKE=${CMAKE:-cmake} - MASON_XC_ROOT="`${CMAKE} -P cmake/mason.cmake PREFIX android-ndk VERSION ${NDK_ANDROID_VERSION}-${MASON_NDK_VERSION}`" - - local TOOLCHAIN="${MASON_XC_ROOT}/toolchain.cmake" - if [ ! -f "${TOOLCHAIN}" ]; then - error "Can't find CMake toolchain file at ${TOOLCHAIN}." - exit 1 - fi - - info "Using Mason-provided Android NDK ${MASON_NDK_VERSION} at ${MASON_XC_ROOT}" - echo CMAKE=\"${CMAKE}\" - echo CMAKE_GENERATOR=\"Ninja\" - echo CMAKE_ARGS=\" \ - -DCMAKE_MAKE_PROGRAM=`pwd`/${NINJA} \ - -DMASON_XC_ROOT=${MASON_XC_ROOT} \ - -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} \ - \" -} - -function system_ndk { - if [[ ${USE_MASON_NDK:-} ]]; then - return 1 - fi - - if [ -f platform/android/local.properties ]; then - local SDK_DIR=$(sed -n -e 's/^sdk.dir=\(.*\)$/\1/p' platform/android/local.properties) - fi - - if [ ! -d "${SDK_DIR:-}" ]; then - if [ ! -z "${ANDROID_HOME:-}" ]; then - local SDK_DIR="${ANDROID_HOME}" - else - error "Can't find the Android SDK. Set \$ANDROID_HOME to the SDK path." - exit 1 - fi - fi - - local NDK_DIR="${ANDROID_NDK_HOME:-${SDK_DIR}/ndk-bundle}" - if [ ! -d "${NDK_DIR}" ]; then - warning "Can't find the Android NDK. If it is installed, set \$ANDROID_NDK_HOME to the NDK path." - return 1 - fi - - local SYSTEM_NDK_VERSION=$(sed -n 's/^Pkg.Revision *= *//p' "${NDK_DIR}/source.properties") - if ! is_supported_ndk_version "${SYSTEM_NDK_VERSION}"; then - warning "Android NDK version '${SYSTEM_NDK_VERSION}' doesn't match required version." - return 1 - fi - - # Try to install CMake if it's not installed yet. - mkdir -p "${SDK_DIR}/cmake" - local CMAKE_VERSION=/$(ls "${SDK_DIR}/cmake" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1) - local CMAKE="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/cmake" - if [ ! -f "${CMAKE}" ]; then - status "Trying to install CMake..." - mkdir -p "${SDK_DIR}/licenses" - echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${SDK_DIR}/licenses/android-sdk-license" - "${SDK_DIR}/tools/bin/sdkmanager" --list | grep cmake | tail -n 1 | cut -d \| -f 1 | xargs "${SDK_DIR}/tools/bin/sdkmanager" >&2 - CMAKE_VERSION=/$(ls "${SDK_DIR}/cmake" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1) - CMAKE="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/cmake" - if [ ! -f "${CMAKE}" ]; then - error "Can't find CMake at ${CMAKE}." - return 1 - fi - fi - - local NINJA="${SDK_DIR}/cmake${CMAKE_VERSION:-}/bin/ninja" - if [ ! -f "${NINJA}" ]; then - error "Can't find Ninja at ${NINJA}." - return 1 - fi - - local TOOLCHAIN="${NDK_DIR}/build/cmake/android.toolchain.cmake" - if [ ! -f "${TOOLCHAIN}" ]; then - error "Can't find CMake toolchain file at ${TOOLCHAIN}." - return 1 - fi - - info "Using system-provided Android NDK ${SYSTEM_NDK_VERSION} at ${NDK_DIR}" - echo CMAKE=\"${CMAKE}\" - echo CMAKE_GENERATOR=\"Android Gradle - Ninja\" - echo CMAKE_ARGS=\" \ - -DANDROID_ABI=${ANDROID_ABI} \ - -DANDROID_NDK=${NDK_DIR} \ - -DCMAKE_MAKE_PROGRAM=${NINJA} \ - -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} \ - -DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \ - -DANDROID_TOOLCHAIN=clang \ - -DANDROID_STL=c++_static \ - -DANDROID_CPP_FEATURES=rtti\;exceptions \ - \" -} - -system_ndk || mason_ndk diff --git a/platform/android/tests/docs/UI_TESTS.md b/platform/android/tests/docs/UI_TESTS.md index 9341cf1e1e..6d8541a406 100644 --- a/platform/android/tests/docs/UI_TESTS.md +++ b/platform/android/tests/docs/UI_TESTS.md @@ -25,7 +25,7 @@ On a terminal, within `mapbox-gl-native/android/java`, run the tests (`cC` stands for `connectedCheck`): ``` -$ ./gradlew cC -p MapboxGLAndroidSDKTestApp +$ ./gradlew -Pmapbox.abis=all cC -p MapboxGLAndroidSDKTestApp ``` Then: @@ -59,7 +59,7 @@ You can generate JaCoCo reports from espresso tests by - running the gradle task `createMockDebugCoverageReport` when executing tests. ## Running Espresso test automatically on AWS Device Farm -To run tests on AWS device farm you need to execute `./gradlew devicefarmUpload`. +To run tests on AWS device farm you need to execute `./gradlew -Pmapbox.abis=none devicefarmUpload`. You can configure the different steps in the testapp `build.gradle`. AWS credentials are found in bitrise. diff --git a/platform/android/tests/docs/UNIT_TESTS.md b/platform/android/tests/docs/UNIT_TESTS.md index e32a36ef78..fefb435684 100644 --- a/platform/android/tests/docs/UNIT_TESTS.md +++ b/platform/android/tests/docs/UNIT_TESTS.md @@ -69,7 +69,7 @@ If you like, you can also run with test coverage enabled. This will show you the You can also run the tests from the command line with: ``` -$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp +$ ./gradlew -Pmapbox.abis=none test -p MapboxGLAndroidSDKTestApp ``` ## Running Unit tests on CI @@ -80,7 +80,7 @@ fails, this will fail and stop the build. You can find this gradle command in our [buildscript](https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/bitrise.yml#L48): ``` -$ ./gradlew testReleaseUnitTest --continue +$ ./gradlew -Pmapbox.abis=none testReleaseUnitTest ``` |