build.gradle 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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"
  6. android {
  7. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  8. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  9. ndkPath PROP_NDK_PATH
  10. compileOptions {
  11. sourceCompatibility JavaVersion.VERSION_1_8
  12. targetCompatibility JavaVersion.VERSION_1_8
  13. }
  14. defaultConfig {
  15. // applicationId APPLICATION_ID
  16. applicationId "${PACKAGE_NAME}"
  17. minSdkVersion PROP_MIN_SDK_VERSION
  18. targetSdkVersion PROP_TARGET_SDK_VERSION
  19. multiDexEnabled true
  20. versionCode "${VERSION_CODE}".toInteger()
  21. versionName "${VERSION_NAME}"
  22. externalNativeBuild {
  23. cmake {
  24. targets "cocos"
  25. arguments "-DRES_DIR=${RES_PATH}", "-DCOCOS_X_PATH=${COCOS_ENGINE_PATH}", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE", "-DANDROID_LD=gold"
  26. cppFlags "-frtti -fexceptions -fsigned-char"
  27. }
  28. ndk { abiFilters PROP_APP_ABI.split(':') }
  29. }
  30. }
  31. sourceSets.main {
  32. java.srcDirs "../src", "src"
  33. res.srcDirs "../res", 'res'
  34. jniLibs.srcDirs "../libs", 'libs'
  35. manifest.srcFile "AndroidManifest.xml"
  36. assets.srcDir "assets"
  37. jniLibs {
  38. // Vulkan validation layer
  39. // srcDir "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"
  40. }
  41. }
  42. externalNativeBuild {
  43. cmake {
  44. path "../CMakeLists.txt"
  45. buildStagingDirectory "${RES_PATH}/proj/build"
  46. }
  47. }
  48. signingConfigs {
  49. release {
  50. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  51. storeFile file(RELEASE_STORE_FILE)
  52. storePassword RELEASE_STORE_PASSWORD
  53. keyAlias RELEASE_KEY_ALIAS
  54. keyPassword RELEASE_KEY_PASSWORD
  55. }
  56. }
  57. }
  58. buildTypes {
  59. release {
  60. debuggable false
  61. jniDebuggable false
  62. renderscriptDebuggable false
  63. if (project.hasProperty("RELEASE_STORE_FILE")) {
  64. signingConfig signingConfigs.release
  65. }
  66. /**
  67. * 配置BuildConfig自动获取字段
  68. */
  69. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  70. buildConfigField "String", "JL_AID", "${JL_AID}"
  71. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  72. buildConfigField "String", "KS_AID", "${KS_AID}"
  73. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  74. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  75. buildConfigField "String", "UM_AID", "${UM_AID}"
  76. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  77. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  78. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  79. buildConfigField "String", "TOPON", "${TOPON}"
  80. }
  81. debug {
  82. debuggable true
  83. jniDebuggable true
  84. renderscriptDebuggable true
  85. signingConfig signingConfigs.release
  86. buildConfigField "String", "TF_CHANNEL", "${TF_CHANNEL}"
  87. buildConfigField "String", "JL_AID", "${JL_AID}"
  88. buildConfigField "String", "JL_CHANNEL", "${JL_CHANNEL}"
  89. buildConfigField "String", "KS_AID", "${KS_AID}"
  90. buildConfigField "String", "KS_ANAME", "${KS_ANAME}"
  91. buildConfigField "String", "KS_CHANNEL", "${KS_CHANNEL}"
  92. buildConfigField "String", "UM_AID", "${UM_AID}"
  93. buildConfigField "String", "UM_CHANNEL", "${UM_CHANNEL}"
  94. buildConfigField "String", "UM_SECRET", "${UM_SECRET}"
  95. buildConfigField "String", "WX_APP_ID", "${WX_APP_ID}"
  96. buildConfigField "String", "TOPON", "${TOPON}"
  97. }
  98. }
  99. //CONFIG IN SERVER
  100. // applicationVariants.all { variant ->
  101. // variant.outputs.all {
  102. // variant.getPackageApplication().outputDirectory = new File("./release")
  103. // }
  104. // }
  105. }
  106. android.applicationVariants.all { variant ->
  107. def outputDir = "${projectDir}/assets"
  108. def sourceDir = "${RES_PATH}/assets"
  109. // assert file("${sourceDir}/res").exists()
  110. delete "${outputDir}"
  111. def targetName = variant.name.capitalize()
  112. def copyTaskName = "copy${targetName}ResourcesToAssets"
  113. tasks.register(copyTaskName) {
  114. copy {
  115. from sourceDir
  116. into outputDir
  117. }
  118. }
  119. tasks.getByName("pre${targetName}Build").dependsOn copyTaskName
  120. }
  121. dependencies {
  122. implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
  123. implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  124. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  125. implementation project(':libservice')
  126. implementation project(':libcocos')
  127. implementation "com.android.support:design:27.1.1"
  128. implementation 'com.android.support:multidex:1.0.3'
  129. implementation "com.android.support:support-v4:27.1.1"
  130. implementation "com.android.support:appcompat-v7:27.1.1"
  131. implementation "com.android.support:recyclerview-v7:27.1.1"
  132. implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+"
  133. implementation "com.github.bumptech.glide:glide:4.8.0"
  134. annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
  135. }