build.gradle 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. apply plugin: 'com.android.application'
  2. RES_PATH = RES_PATH.replace("\\", "/")
  3. COCOS_ENGINE_PATH = COCOS_ENGINE_PATH.replace("\\", "/")
  4. buildDir = "${RES_PATH}/proj/build/${project.name ==~ /^[_a-zA-Z0-9-]+$/ ? project.name : 'CocosGame'}"
  5. android {
  6. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  7. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  8. ndkPath PROP_NDK_PATH
  9. namespace NAME_SPACE
  10. compileOptions {
  11. sourceCompatibility JavaVersion.VERSION_1_8
  12. targetCompatibility JavaVersion.VERSION_1_8
  13. }
  14. defaultConfig {
  15. applicationId APPLICATION_ID
  16. minSdkVersion PROP_MIN_SDK_VERSION
  17. targetSdkVersion PROP_TARGET_SDK_VERSION
  18. versionCode 102
  19. versionName "1.0.2"
  20. externalNativeBuild {
  21. cmake {
  22. targets "cocos"
  23. arguments "-DRES_DIR=${RES_PATH}", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
  24. }
  25. ndk { abiFilters PROP_APP_ABI.split(':') }
  26. }
  27. }
  28. sourceSets.main {
  29. java.srcDirs "../src", "src"
  30. res.srcDirs "../res", 'res', "${RES_PATH}/proj/res"
  31. jniLibs.srcDirs "../libs", 'libs'
  32. manifest.srcFile "AndroidManifest.xml"
  33. assets.srcDirs "${RES_PATH}/data", "src/main/assets"
  34. jniLibs {
  35. // Vulkan validation layer
  36. // srcDir "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"
  37. }
  38. }
  39. externalNativeBuild {
  40. cmake {
  41. version "3.22.1"
  42. path "../CMakeLists.txt"
  43. buildStagingDirectory "${RES_PATH}/proj/build"
  44. }
  45. }
  46. signingConfigs {
  47. release {
  48. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  49. storeFile file(RELEASE_STORE_FILE)
  50. storePassword RELEASE_STORE_PASSWORD
  51. keyAlias RELEASE_KEY_ALIAS
  52. keyPassword RELEASE_KEY_PASSWORD
  53. }
  54. }
  55. }
  56. def appName = URLDecoder.decode("${PROP_APP_NAME}", "UTF-8")
  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. resValue "string", "app_name", "${appName}"
  78. buildConfigField "String", "ATMOB_CENTRAL_APP_KEY", "\"$atmob_central_app_key\""
  79. buildConfigField "String", "GRAVITY_ACCESS_TOKEN", "\"$gravity_access_token\""
  80. buildConfigField "String", "TEST_CHANNEL", "\"$test_channel\""
  81. buildConfigField "String", "YIDUN_PRODUCT_ID", "\"$yidun_product_id\""
  82. buildConfigField "String", "YIDUN_REGISTER_BUSINESS_ID", "\"$yidun_register_business_id\""
  83. buildConfigField "String", "WECHAT_APP_ID", "\"$wechat_app_id\""
  84. buildConfigField "String", "ALIPAY_APP_ID", "\"$alipay_app_id\""
  85. buildConfigField "String", "UMENG_APP_KEY", "\"$umeng_app_key\""
  86. buildConfigField "String", "PROD_SERVER_HOST", "\"$prod_server_host\""
  87. buildConfigField "String", "TEST_SERVER_HOST", "\"$test_server_host\""
  88. buildConfigField "boolean", "IS_PROD_SERVER", "true"
  89. }
  90. debug {
  91. debuggable true
  92. jniDebuggable true
  93. renderscriptDebuggable true
  94. minifyEnabled false
  95. shrinkResources false
  96. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  97. if (project.hasProperty("RELEASE_STORE_FILE")) {
  98. signingConfig signingConfigs.release
  99. }
  100. externalNativeBuild {
  101. cmake {
  102. // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden`
  103. arguments "-DHIDE_SYMBOLS=ON"
  104. }
  105. }
  106. if (!Boolean.parseBoolean(PROP_IS_DEBUG)) {
  107. getIsDefault().set(true)
  108. }
  109. resValue "string", "app_name", "${appName}-debug"
  110. buildConfigField "String", "ATMOB_CENTRAL_APP_KEY", "\"$atmob_central_app_key\""
  111. buildConfigField "String", "GRAVITY_ACCESS_TOKEN", "\"$gravity_access_token\""
  112. buildConfigField "String", "TEST_CHANNEL", "\"$test_channel\""
  113. buildConfigField "String", "YIDUN_PRODUCT_ID", "\"$yidun_product_id\""
  114. buildConfigField "String", "YIDUN_REGISTER_BUSINESS_ID", "\"$yidun_register_business_id\""
  115. buildConfigField "String", "WECHAT_APP_ID", "\"$wechat_app_id\""
  116. buildConfigField "String", "ALIPAY_APP_ID", "\"$alipay_app_id\""
  117. buildConfigField "String", "UMENG_APP_KEY", "\"$umeng_app_key\""
  118. buildConfigField "String", "PROD_SERVER_HOST", "\"$prod_server_host\""
  119. buildConfigField "String", "TEST_SERVER_HOST", "\"$test_server_host\""
  120. buildConfigField "boolean", "IS_PROD_SERVER", "false"
  121. }
  122. }
  123. buildFeatures {
  124. buildConfig = true
  125. }
  126. configurations.configureEach {
  127. resolutionStrategy {
  128. // don't cache changing modules at all
  129. cacheChangingModulesFor 10, 'seconds'
  130. }
  131. }
  132. applicationVariants.configureEach { variant ->
  133. def date = new Date().format("YYMMddHHmmss")
  134. variant.outputs.configureEach {
  135. def fileName = "${defaultConfig.applicationId}" +
  136. "-v${defaultConfig.versionName}" +
  137. "-${variant.buildType.name}" +
  138. "-${date}" +
  139. ".apk"
  140. outputFileName = fileName
  141. }
  142. }
  143. }
  144. dependencies {
  145. implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
  146. implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  147. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  148. implementation project(':libservice')
  149. implementation project(':libcocos')
  150. if (Boolean.parseBoolean(PROP_ENABLE_INPUTSDK)) {
  151. implementation 'com.google.android.libraries.play.games:inputmapping:1.1.0-beta'
  152. implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.10"
  153. }
  154. implementation "atmob.central:cocos-bridge:0.0.1-SNAPSHOT"
  155. implementation "androidx.constraintlayout:constraintlayout:2.1.4"
  156. }