build.gradle 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. } else {
  24. arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
  25. }
  26. arguments '-j' + Runtime.runtime.availableProcessors()
  27. abiFilters.addAll(PROP_APP_ABI.split(':').collect { it as String })
  28. }
  29. }
  30. }
  31. }
  32. sourceSets.main {
  33. java.srcDirs "../src", "src"
  34. res.srcDirs "../res", 'res'
  35. jniLibs.srcDirs "../libs", 'libs'
  36. manifest.srcFile "AndroidManifest.xml"
  37. }
  38. externalNativeBuild {
  39. ndkBuild {
  40. if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
  41. // skip the NDK Build step if PROP_NDK_MODE is none
  42. path "jni/Android.mk"
  43. }
  44. }
  45. }
  46. signingConfigs {
  47. release {
  48. if (project.hasProperty("RELEASE_STORE_FILE")) {
  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. buildTypes {
  57. release {
  58. debuggable false
  59. jniDebuggable false
  60. renderscriptDebuggable false
  61. minifyEnabled true
  62. shrinkResources true
  63. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  64. if (project.hasProperty("RELEASE_STORE_FILE")) {
  65. signingConfig signingConfigs.release
  66. }
  67. externalNativeBuild {
  68. ndkBuild {
  69. arguments 'NDK_DEBUG=0'
  70. }
  71. }
  72. }
  73. debug {
  74. debuggable true
  75. jniDebuggable true
  76. renderscriptDebuggable true
  77. externalNativeBuild {
  78. ndkBuild {
  79. arguments 'NDK_DEBUG=1'
  80. }
  81. }
  82. }
  83. }
  84. }
  85. android.featureVariants.all { variant ->
  86. // delete previous files first
  87. delete "${buildDir}/intermediates/merged_assets/"
  88. variant.mergeAssets.doLast {
  89. def sourceDir = "${buildDir}/../../../../.."
  90. copy {
  91. from "${sourceDir}/assets"
  92. into "${outputDir}/assets"
  93. }
  94. copy {
  95. from "${sourceDir}/src"
  96. into "${outputDir}/src"
  97. }
  98. copy {
  99. from "${sourceDir}/jsb-adapter"
  100. into "${outputDir}/jsb-adapter"
  101. }
  102. copy {
  103. from "${sourceDir}/main.js"
  104. from "${sourceDir}/project.json"
  105. into outputDir
  106. }
  107. }
  108. }
  109. dependencies {
  110. implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
  111. implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  112. implementation fileTree(dir: "G:/CocosCreator/cocoscreator_ide/CocosCreator_v2.4.0_20200622_win/resources/cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar'])
  113. implementation 'com.google.android.instantapps:instantapps:1.1.0'
  114. implementation project(':libcocos2dx')
  115. }