build.gradle 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. ndkPath PROP_NDK_PATH
  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. externalNativeBuild {
  37. cmake {
  38. version "3.22.1"
  39. path "../CMakeLists.txt"
  40. buildStagingDirectory "${RES_PATH}/proj/build"
  41. }
  42. }
  43. signingConfigs {
  44. release {
  45. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  46. storeFile file(RELEASE_STORE_FILE)
  47. storePassword RELEASE_STORE_PASSWORD
  48. keyAlias RELEASE_KEY_ALIAS
  49. keyPassword RELEASE_KEY_PASSWORD
  50. }
  51. }
  52. }
  53. buildTypes {
  54. release {
  55. debuggable false
  56. jniDebuggable false
  57. renderscriptDebuggable false
  58. minifyEnabled true
  59. shrinkResources true
  60. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  61. if (project.hasProperty("RELEASE_STORE_FILE")) {
  62. signingConfig signingConfigs.release
  63. }
  64. externalNativeBuild {
  65. cmake {
  66. // switch HIDE_SYMBOLS to OFF to skip compilation flag `-fvisibility=hidden`
  67. arguments "-DHIDE_SYMBOLS=ON"
  68. }
  69. }
  70. }
  71. debug {
  72. debuggable true
  73. jniDebuggable true
  74. renderscriptDebuggable true
  75. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  76. // applicationIdSuffix ".debug"
  77. }
  78. }
  79. }
  80. dependencies {
  81. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  82. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  83. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  84. implementation project(':libservice')
  85. implementation project(':libcocos')
  86. }