build.gradle 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. multiDexEnabled true
  13. ndk {
  14. abiFilters 'armeabi-v7a'
  15. }
  16. externalNativeBuild {
  17. ndkBuild {
  18. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  19. // skip the NDK Build step if PROP_NDK_MODE is none
  20. targets 'cocos2djs'
  21. arguments 'NDK_TOOLCHAIN_VERSION=clang'
  22. def module_paths = [project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x"),
  23. project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/cocos"),
  24. project.file("${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/external")]
  25. if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  26. arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
  27. }
  28. else {
  29. arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
  30. }
  31. arguments '-j' + Runtime.runtime.availableProcessors()
  32. abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
  33. }
  34. }
  35. }
  36. }
  37. sourceSets.main {
  38. java.srcDirs "../src", "src"
  39. res.srcDirs "../res", 'res'
  40. jniLibs.srcDirs "../libs", 'libs'
  41. res.srcDirs += "libs/topon/res" //这边是全路径
  42. manifest.srcFile "AndroidManifest.xml"
  43. }
  44. externalNativeBuild {
  45. ndkBuild {
  46. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  47. // skip the NDK Build step if PROP_NDK_MODE is none
  48. path "jni/Android.mk"
  49. }
  50. }
  51. }
  52. signingConfigs {
  53. release {
  54. if (project.hasProperty("RELEASE_STORE_FILE")) {
  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. ndkBuild {
  75. arguments 'NDK_DEBUG=0'
  76. }
  77. }
  78. //FC:生成BuildConfig文件
  79. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  80. buildConfigField "String", "JL_AID", "${JL_AID}"
  81. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  82. buildConfigField "String", "KS_AID", "${KS_AID}"
  83. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  84. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  85. buildConfigField "String", "UM_AID", "${UM_AID}"
  86. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  87. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  88. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  89. buildConfigField "String", "TOPON", "${TOPON}"
  90. }
  91. debug {
  92. debuggable true
  93. jniDebuggable true
  94. renderscriptDebuggable true
  95. externalNativeBuild {
  96. ndkBuild {
  97. arguments 'NDK_DEBUG=1'
  98. }
  99. }
  100. //FC:生成BuildConfig文件
  101. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  102. buildConfigField "String", "JL_AID", "${JL_AID}"
  103. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  104. buildConfigField "String", "KS_AID", "${KS_AID}"
  105. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  106. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  107. buildConfigField "String", "UM_AID", "${UM_AID}"
  108. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  109. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  110. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  111. buildConfigField "String", "TOPON", "${TOPON}"
  112. }
  113. }
  114. }
  115. android.applicationVariants.all { variant ->
  116. // delete previous files first
  117. delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
  118. variant.mergeAssets.doLast {
  119. def sourceDir = "${buildDir}/../../../../.."
  120. copy {
  121. from "${sourceDir}"
  122. include "assets/**"
  123. include "src/**"
  124. include "jsb-adapter/**"
  125. into outputDir
  126. }
  127. copy {
  128. from "${sourceDir}/main.js"
  129. from "${sourceDir}/project.json"
  130. into outputDir
  131. }
  132. }
  133. }
  134. dependencies {
  135. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  136. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  137. implementation fileTree(dir: "${System.getenv("COCOSCREATOR_HOME")}/resources/.editors/Creator/2.4.5/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
  138. implementation project(':libcocos2dx')
  139. //微信SDK(登录、分享等)
  140. api 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
  141. //聚合SDK
  142. api 'com.android.support:appcompat-v7:28.0.0' //Gradle中要补充Support v7插件的引入,否则会集成失败
  143. api fileTree(include: ['*.jar','*.aar'], dir: 'libs/topon')
  144. api fileTree(include: ['*.jar','*.aar'], dir: 'libs/topon/libs')
  145. api 'com.android.support:design:28.0.0'//从v5.6.2版本开始,如果有聚合快手的v2.7.2及以上版本需要添加此依赖
  146. implementation 'com.android.support:multidex:1.0.3' //应对接入后发布报single dex相关错误,defaultConfig中需同步设置multiDexEnabled true
  147. //OaidSDK
  148. api fileTree(include: ['*.jar','*.aar'], dir: 'libs/oaid')
  149. }