build.gradle 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import org.apache.tools.ant.taskdefs.condition.Os
  2. apply plugin: 'com.android.application'
  3. android {
  4. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  5. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  6. defaultConfig {
  7. applicationId "com.aries.ttaxx"
  8. minSdkVersion PROP_MIN_SDK_VERSION
  9. targetSdkVersion PROP_TARGET_SDK_VERSION
  10. versionCode 1
  11. versionName "1.0"
  12. externalNativeBuild {
  13. ndkBuild {
  14. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  15. // skip the NDK Build step if PROP_NDK_MODE is none
  16. targets 'cocos2djs'
  17. arguments 'NDK_TOOLCHAIN_VERSION=clang'
  18. def module_paths = [project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x"),
  19. project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/cocos"),
  20. project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/external")]
  21. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  22. arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
  23. }
  24. else {
  25. arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
  26. }
  27. arguments '-j' + Runtime.runtime.availableProcessors()
  28. abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
  29. }
  30. }
  31. }
  32. }
  33. sourceSets.main {
  34. java.srcDirs "../src", "src"
  35. res.srcDirs "../res", 'res'
  36. jniLibs.srcDirs "../libs", 'libs'
  37. manifest.srcFile "AndroidManifest.xml"
  38. }
  39. externalNativeBuild {
  40. ndkBuild {
  41. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  42. // skip the NDK Build step if PROP_NDK_MODE is none
  43. path "jni/Android.mk"
  44. }
  45. }
  46. }
  47. signingConfigs {
  48. release {
  49. if (project.hasProperty("RELEASE_STORE_FILE")) {
  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. ndkBuild {
  70. arguments 'NDK_DEBUG=0'
  71. }
  72. }
  73. //FC:生成BuildConfig文件
  74. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  75. buildConfigField "String", "JL_AID", "${JL_AID}"
  76. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  77. buildConfigField "String", "KS_AID", "${KS_AID}"
  78. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  79. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  80. buildConfigField "String", "UM_AID", "${UM_AID}"
  81. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  82. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  83. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  84. buildConfigField "String", "TOPON", "${TOPON}"
  85. }
  86. debug {
  87. debuggable true
  88. jniDebuggable true
  89. renderscriptDebuggable true
  90. externalNativeBuild {
  91. ndkBuild {
  92. arguments 'NDK_DEBUG=1'
  93. }
  94. }
  95. //FC:生成BuildConfig文件
  96. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  97. buildConfigField "String", "JL_AID", "${JL_AID}"
  98. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  99. buildConfigField "String", "KS_AID", "${KS_AID}"
  100. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  101. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  102. buildConfigField "String", "UM_AID", "${UM_AID}"
  103. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  104. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  105. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  106. buildConfigField "String", "TOPON", "${TOPON}"
  107. }
  108. }
  109. }
  110. android.applicationVariants.all { variant ->
  111. // delete previous files first
  112. delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
  113. variant.mergeAssets.doLast {
  114. def sourceDir = "${buildDir}/../../../../.."
  115. copy {
  116. from "${sourceDir}"
  117. include "assets/**"
  118. include "src/**"
  119. include "jsb-adapter/**"
  120. into outputDir
  121. }
  122. copy {
  123. from "${sourceDir}/main.js"
  124. from "${sourceDir}/project.json"
  125. into outputDir
  126. }
  127. }
  128. }
  129. dependencies {
  130. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  131. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  132. implementation fileTree(dir: "${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
  133. implementation project(':libcocos2dx')
  134. }