From 412a6fa9e2d8cdc6bde09526a23ab402f2d02615 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 15 May 2021 00:12:41 +0800 Subject: [PATCH] Fix android ci [ci build] --- .../proj.android/app/build.gradle | 9 +++++++++ .../runtime-src/proj.android/app/build.gradle | 9 +++++++++ .../proj.android/app/build.gradle | 9 +++++++++ tests/cpp-tests/proj.android/app/build.gradle | 9 +++++++++ .../proj.android/app/build.gradle | 9 +++++++++ .../project/proj.android/app/build.gradle | 9 +++++++++ .../project/proj.android/app/build.gradle | 9 +++++++++ .../proj.android/app/build.gradle | 9 +++++++++ tools/appveyor-scripts/setup_android.py | 20 ++++++++++--------- 9 files changed, 83 insertions(+), 9 deletions(-) diff --git a/templates/cpp-template-default/proj.android/app/build.gradle b/templates/cpp-template-default/proj.android/app/build.gradle index a16757641a..bdd987b91f 100644 --- a/templates/cpp-template-default/proj.android/app/build.gradle +++ b/templates/cpp-template-default/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.hellocpp" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle b/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle index 9c3bb143dd..5d9ec34f22 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem; +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.hellolua" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/cpp-empty-test/proj.android/app/build.gradle b/tests/cpp-empty-test/proj.android/app/build.gradle index 620653aebf..3553234660 100644 --- a/tests/cpp-empty-test/proj.android/app/build.gradle +++ b/tests/cpp-empty-test/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.cpp_empty_test" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/cpp-tests/proj.android/app/build.gradle b/tests/cpp-tests/proj.android/app/build.gradle index 0f792a9115..7af11d39e9 100644 --- a/tests/cpp-tests/proj.android/app/build.gradle +++ b/tests/cpp-tests/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem; +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.cpp_tests" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/fairygui-tests/proj.android/app/build.gradle b/tests/fairygui-tests/proj.android/app/build.gradle index 0c77f2298d..ec33d37ca6 100644 --- a/tests/fairygui-tests/proj.android/app/build.gradle +++ b/tests/fairygui-tests/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.fairygui_tests" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/lua-empty-test/project/proj.android/app/build.gradle b/tests/lua-empty-test/project/proj.android/app/build.gradle index 9936fc1879..2bb6181362 100644 --- a/tests/lua-empty-test/project/proj.android/app/build.gradle +++ b/tests/lua-empty-test/project/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem; +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.lua_empty_test" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/lua-tests/project/proj.android/app/build.gradle b/tests/lua-tests/project/proj.android/app/build.gradle index 7a3347d1da..3cbbac256a 100644 --- a/tests/lua-tests/project/proj.android/app/build.gradle +++ b/tests/lua-tests/project/proj.android/app/build.gradle @@ -1,10 +1,19 @@ import org.gradle.internal.os.OperatingSystem; +import java.nio.file.Paths +import java.nio.file.Files apply plugin: 'com.android.application' android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.lua_tests" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tests/performance-tests/proj.android/app/build.gradle b/tests/performance-tests/proj.android/app/build.gradle index da0ba02830..f34665868f 100644 --- a/tests/performance-tests/proj.android/app/build.gradle +++ b/tests/performance-tests/proj.android/app/build.gradle @@ -1,8 +1,17 @@ apply plugin: 'com.android.application' +import java.nio.file.Paths +import java.nio.file.Files android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() + // setup ndk + ndkVersion = "19.2.5345600" + def ANDROID_NDK = Paths.get("${System.env.ANDROID_NDK}") + if(Files.exists(ANDROID_NDK)) { + ndkPath = ANDROID_NDK.toAbsolutePath().toString() + } + defaultConfig { applicationId "org.cocos2dx.performance_tests" minSdkVersion PROP_MIN_SDK_VERSION diff --git a/tools/appveyor-scripts/setup_android.py b/tools/appveyor-scripts/setup_android.py index 5271902de5..70cff0420b 100644 --- a/tools/appveyor-scripts/setup_android.py +++ b/tools/appveyor-scripts/setup_android.py @@ -27,10 +27,11 @@ COCOS2D_X = os.path.abspath(os.path.join(DIR_PATH, "../..")) # ROOT_DIR/cocos2d-x ROOT_DIR = os.path.abspath(os.path.join(COCOS2D_X, "..")) -NDK_VER = "r19c" +NDK_VER = "19.2.5345600" # "r19c" -ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER) +# ANDROID_NDK = os.path.join(ROOT_DIR, "android-ndk-" + NDK_VER) ANDROID_SDK = os.path.join(ROOT_DIR, "android-sdk") +ANDROID_NDK = os.path.join(ANDROID_SDK, "ndk/" + NDK_VER) SDK_MANAGER = os.path.join(ROOT_DIR, "cmdline-tools/bin/sdkmanager") SYSTEM = platform.system().lower() if SYSTEM == "windows": @@ -107,7 +108,8 @@ def install_android_sdk(): 'platform-tools', 'cmdline-tools;latest', 'platforms;android-28', - 'build-tools;29.0.2' + 'build-tools;29.0.2', + 'ndk:' + NDK_VER ] cmd = cmd1 + " ".join(packages) @@ -120,20 +122,20 @@ def export_environment(ndk_only): myfile.write("export ANDROID_HOME=" + ANDROID_SDK + "\n") myfile.write("export ANDROID_SDK_ROOT=" + ANDROID_SDK + "\n") myfile.write("export ANDROID_NDK_HOME=" + ANDROID_NDK + "\n") - myfile.write("export NDK_ROOT=" + ANDROID_NDK + "\n") + myfile.write("export ANDROID_NDK=" + ANDROID_NDK + "\n") with open(os.path.join(ROOT_DIR, "environment.ps1"), "a") as myfile: if not ndk_only: myfile.write("$env:ANDROID_HOME=\"" + ANDROID_SDK + "\"\n") myfile.write("$env:ANDROID_SDK_ROOT=\"" + ANDROID_SDK + "\"\n") myfile.write("$env:ANDROID_NDK_HOME=\"" + ANDROID_NDK + "\"\n") - myfile.write("$env:NDK_ROOT=\"" + ANDROID_NDK + "\"\n") + myfile.write("$env:ANDROID_NDK=\"" + ANDROID_NDK + "\"\n") def main(ndk_only): - if not ndk_only: - install_android_cmdline_tools() - install_android_sdk() - install_android_ndk() + # if not ndk_only: + install_android_cmdline_tools() + install_android_sdk() + # install_android_ndk() export_environment(ndk_only)