build.gradle 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. 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"
  25. }
  26. ndk { abiFilters PROP_APP_ABI.split(':') }
  27. }
  28. }
  29. sourceSets.main {
  30. java.srcDirs "../src", "src"
  31. res.srcDirs "../res", 'res'
  32. jniLibs.srcDirs "../libs", 'libs'
  33. manifest.srcFile "AndroidManifest.xml"
  34. assets.srcDir "${RES_PATH}/assets"
  35. jniLibs {
  36. // Vulkan validation layer
  37. // srcDir "${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"
  38. }
  39. }
  40. externalNativeBuild {
  41. cmake {
  42. path "../CMakeLists.txt"
  43. buildStagingDirectory "${RES_PATH}/proj/build"
  44. }
  45. }
  46. signingConfigs {
  47. release {
  48. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  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. // resValue "string", "app_name", PROP_APP_NAME
  68. }
  69. debug {
  70. debuggable true
  71. jniDebuggable true
  72. renderscriptDebuggable true
  73. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  74. // applicationIdSuffix ".debug"
  75. }
  76. }
  77. }
  78. dependencies {
  79. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  80. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  81. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  82. implementation project(':libservice')
  83. implementation project(':libcocos')
  84. }