build.gradle 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/instantapp"
  6. android {
  7. compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
  8. buildToolsVersion PROP_BUILD_TOOLS_VERSION
  9. ndkVersion PROP_NDK_VERSION
  10. namespace APPLICATION_ID
  11. compileOptions {
  12. sourceCompatibility JavaVersion.VERSION_1_8
  13. targetCompatibility JavaVersion.VERSION_1_8
  14. }
  15. defaultConfig {
  16. minSdkVersion PROP_MIN_SDK_VERSION
  17. targetSdkVersion PROP_TARGET_SDK_VERSION
  18. versionCode 1
  19. versionName "1.0"
  20. externalNativeBuild {
  21. cmake {
  22. targets "cocos"
  23. 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"
  24. cppFlags "-frtti -fexceptions -fsigned-char -DANDROID_INSTANT=1"
  25. }
  26. ndk { abiFilters PROP_APP_ABI.split(':') }
  27. }
  28. }
  29. sourceSets.main {
  30. java.srcDirs "../src", "src"
  31. res.srcDirs "../res", 'res', "${RES_PATH}/proj/res"
  32. jniLibs.srcDirs "../libs", 'libs'
  33. manifest.srcFile "AndroidManifest.xml"
  34. assets.srcDir "${RES_PATH}/data"
  35. }
  36. packagingOptions {
  37. jniLibs {
  38. useLegacyPackaging Boolean.parseBoolean(PROP_ENABLE_COMPRESS_SO)
  39. }
  40. }
  41. externalNativeBuild {
  42. cmake {
  43. version "3.22.1"
  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. minifyEnabled true
  64. shrinkResources true
  65. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  66. if (project.hasProperty("RELEASE_STORE_FILE")) {
  67. signingConfig signingConfigs.release
  68. }
  69. externalNativeBuild {
  70. cmake {
  71. // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden`
  72. arguments "-DHIDE_SYMBOLS=ON"
  73. }
  74. }
  75. }
  76. debug {
  77. debuggable true
  78. jniDebuggable true
  79. renderscriptDebuggable true
  80. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  81. // applicationIdSuffix ".debug"
  82. }
  83. }
  84. }
  85. dependencies {
  86. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  87. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  88. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  89. implementation project(':libservice')
  90. implementation project(':libcocos')
  91. }