build.gradle 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. ndkVersion PROP_NDK_VERSION
  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. packagingOptions {
  41. jniLibs {
  42. useLegacyPackaging Boolean.parseBoolean(PROP_ENABLE_COMPRESS_SO)
  43. }
  44. }
  45. externalNativeBuild {
  46. cmake {
  47. version "3.22.1"
  48. path "../CMakeLists.txt"
  49. buildStagingDirectory "${RES_PATH}/proj/build"
  50. }
  51. }
  52. signingConfigs {
  53. release {
  54. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  55. storeFile file(RELEASE_STORE_FILE)
  56. storePassword RELEASE_STORE_PASSWORD
  57. keyAlias RELEASE_KEY_ALIAS
  58. keyPassword RELEASE_KEY_PASSWORD
  59. }
  60. }
  61. }
  62. buildTypes {
  63. release {
  64. debuggable false
  65. jniDebuggable false
  66. renderscriptDebuggable false
  67. minifyEnabled true
  68. shrinkResources true
  69. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  70. if (project.hasProperty("RELEASE_STORE_FILE")) {
  71. signingConfig signingConfigs.release
  72. }
  73. externalNativeBuild {
  74. cmake {
  75. // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden`
  76. arguments "-DHIDE_SYMBOLS=ON"
  77. }
  78. }
  79. if (!Boolean.parseBoolean(PROP_IS_DEBUG)) {
  80. getIsDefault().set(true)
  81. }
  82. }
  83. debug {
  84. debuggable true
  85. jniDebuggable true
  86. renderscriptDebuggable true
  87. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  88. // applicationIdSuffix ".debug"
  89. }
  90. }
  91. }
  92. dependencies {
  93. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  94. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  95. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  96. implementation project(':libservice')
  97. implementation project(':libcocos')
  98. if (Boolean.parseBoolean(PROP_ENABLE_INPUTSDK)) {
  99. implementation 'com.google.android.libraries.play.games:inputmapping:1.1.0-beta'
  100. implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.10"
  101. }
  102. }