build.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import org.apache.tools.ant.taskdefs.condition.Os
  2. apply plugin: 'com.android.feature'
  3. android {
  4. baseFeature true
  5. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  6. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  7. defaultConfig {
  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("G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x"),
  19. project.file("G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x/cocos"),
  20. project.file("G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/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. }
  74. debug {
  75. debuggable true
  76. jniDebuggable true
  77. renderscriptDebuggable true
  78. externalNativeBuild {
  79. ndkBuild {
  80. arguments 'NDK_DEBUG=1'
  81. }
  82. }
  83. }
  84. }
  85. }
  86. android.featureVariants.all { variant ->
  87. // delete previous files first
  88. delete "${buildDir}/intermediates/merged_assets/"
  89. variant.mergeAssets.doLast {
  90. def sourceDir = "${buildDir}/../../../../.."
  91. copy {
  92. from "${sourceDir}/assets"
  93. into "${outputDir}/assets"
  94. }
  95. copy {
  96. from "${sourceDir}/src"
  97. into "${outputDir}/src"
  98. }
  99. copy {
  100. from "${sourceDir}/jsb-adapter"
  101. into "${outputDir}/jsb-adapter"
  102. }
  103. copy {
  104. from "${sourceDir}/main.js"
  105. from "${sourceDir}/project.json"
  106. into outputDir
  107. }
  108. }
  109. }
  110. dependencies {
  111. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  112. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  113. implementation fileTree(dir: "G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
  114. implementation 'com.google.android.instantapps:instantapps:1.1.0'
  115. implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
  116. implementation project(':libcocos2dx')
  117. }