build.gradle 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "com.cocos.android"
  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'
  32. jniLibs.srcDirs "../libs", 'libs'
  33. manifest.srcFile "AndroidManifest.xml"
  34. assets.srcDir "${RES_PATH}/assets"
  35. }
  36. externalNativeBuild {
  37. cmake {
  38. path "../CMakeLists.txt"
  39. buildStagingDirectory "${RES_PATH}/proj/build"
  40. }
  41. }
  42. signingConfigs {
  43. release {
  44. if (project.hasProperty("RELEASE_STORE_FILE") && !RELEASE_STORE_FILE.isEmpty()) {
  45. storeFile file(RELEASE_STORE_FILE)
  46. storePassword RELEASE_STORE_PASSWORD
  47. keyAlias RELEASE_KEY_ALIAS
  48. keyPassword RELEASE_KEY_PASSWORD
  49. }
  50. }
  51. }
  52. buildTypes {
  53. release {
  54. debuggable false
  55. jniDebuggable false
  56. renderscriptDebuggable false
  57. minifyEnabled true
  58. shrinkResources true
  59. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  60. if (project.hasProperty("RELEASE_STORE_FILE")) {
  61. signingConfig signingConfigs.release
  62. }
  63. // resValue "string", "app_name", PROP_APP_NAME
  64. }
  65. debug {
  66. debuggable true
  67. jniDebuggable true
  68. renderscriptDebuggable true
  69. // resValue "string", "app_name", "${PROP_APP_NAME}-dbg"
  70. // applicationIdSuffix ".debug"
  71. }
  72. }
  73. }
  74. dependencies {
  75. implementation fileTree(dir: '../libs', include: ['*.jar','*.aar'])
  76. implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
  77. implementation fileTree(dir: "${COCOS_ENGINE_PATH}/cocos/platform/android/java/libs", include: ['*.jar'])
  78. implementation project(':libservice')
  79. implementation project(':libcocos')
  80. }