build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import org.apache.tools.ant.taskdefs.condition.Os
  2. apply plugin: 'com.android.application'
  3. RES_PATH = RES_PATH.replace("\\", "/")
  4. COCOS_ENGINE_PATH = COCOS_ENGINE_PATH.replace("\\", "/")
  5. buildDir = "${RES_PATH}/proj/build/${project.name ==~ /^[_a-zA-Z0-9-]+$/ ? project.name : 'CocosGame'}"
  6. android {
  7. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  8. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  9. ndkPath PROP_NDK_PATH
  10. namespace APPLICATION_ID
  11. compileOptions {
  12. sourceCompatibility JavaVersion.VERSION_1_8
  13. targetCompatibility JavaVersion.VERSION_1_8
  14. }
  15. defaultConfig {
  16. applicationId APPLICATION_ID
  17. minSdkVersion PROP_MIN_SDK_VERSION
  18. targetSdkVersion PROP_TARGET_SDK_VERSION
  19. versionCode 1
  20. versionName "1.0"
  21. externalNativeBuild {
  22. cmake {
  23. targets "cocos"
  24. arguments "-DRES_DIR=${RES_PATH}", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
  25. }
  26. ndk { abiFilters PROP_APP_ABI.split(':') }
  27. }
  28. }
  29. sourceSets.main {
  30. java.srcDirs "../src", "src"
  31. res.srcDirs "../res", 'res', "${RES_PATH}/proj/res"
  32. jniLibs.srcDirs "../libs", 'libs'
  33. manifest.srcFile "AndroidManifest.xml"
  34. assets.srcDir "${RES_PATH}/data"
  35. jniLibs {
  36. // Vulkan validation layer
  37. // srcDir "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"
  38. }
  39. }
  40. externalNativeBuild {
  41. cmake {
  42. version "3.22.1"
  43. path "../CMakeLists.txt"
  44. buildStagingDirectory "${RES_PATH}/proj/build"
  45. }
  46. }
  47. signingConfigs {
  48. release {
  49. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  50. storeFile file(RELEASE_STORE_FILE)
  51. storePassword RELEASE_STORE_PASSWORD
  52. keyAlias RELEASE_KEY_ALIAS
  53. keyPassword RELEASE_KEY_PASSWORD
  54. }
  55. }
  56. }
  57. buildTypes {
  58. release {
  59. debuggable false
  60. jniDebuggable false
  61. renderscriptDebuggable false
  62. minifyEnabled true
  63. shrinkResources true
  64. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  65. if (project.hasProperty("RELEASE_STORE_FILE")) {
  66. signingConfig signingConfigs.release
  67. }
  68. externalNativeBuild {
  69. cmake {
  70. // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden`
  71. arguments "-DHIDE_SYMBOLS=ON"
  72. }
  73. }
  74. if (!Boolean.parseBoolean(PROP_IS_DEBUG)) {
  75. getIsDefault().set(true)
  76. }
  77. }
  78. debug {
  79. debuggable true
  80. jniDebuggable true
  81. renderscriptDebuggable true
  82. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  83. // applicationIdSuffix ".debug"
  84. }
  85. }
  86. }
  87. dependencies {
  88. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  89. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  90. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  91. implementation project(':libservice')
  92. implementation project(':libcocos')
  93. if (Boolean.parseBoolean(PROP_ENABLE_INPUTSDK)) {
  94. implementation 'com.google.android.libraries.play.games:inputmapping:1.1.0-beta'
  95. implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.10"
  96. }
  97. }