build.gradle 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. apply plugin: 'com.android.application'
  2. // 版本号取自 apps/mobile/package.json:versionCode = 主版本 * 10000 + 次版本 * 100 + 修订号(覆盖安装要求只增不减)
  3. def appVersion = new groovy.json.JsonSlurper().parse(file('../../package.json')).version
  4. def versionParts = appVersion.tokenize('.').collect { it.toInteger() }
  5. android {
  6. namespace = "cc.zenpower.agent"
  7. compileSdk = rootProject.ext.compileSdkVersion
  8. defaultConfig {
  9. applicationId "cc.zenpower.agent"
  10. minSdkVersion rootProject.ext.minSdkVersion
  11. targetSdkVersion rootProject.ext.targetSdkVersion
  12. versionCode versionParts[0] * 10000 + versionParts[1] * 100 + versionParts[2]
  13. versionName appVersion
  14. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  15. aaptOptions {
  16. // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
  17. // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
  18. ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
  19. }
  20. }
  21. buildTypes {
  22. release {
  23. minifyEnabled false
  24. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  25. }
  26. }
  27. }
  28. repositories {
  29. flatDir{
  30. dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
  31. }
  32. }
  33. dependencies {
  34. implementation fileTree(include: ['*.jar'], dir: 'libs')
  35. implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
  36. implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
  37. implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
  38. implementation project(':capacitor-android')
  39. testImplementation "junit:junit:$junitVersion"
  40. androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
  41. androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
  42. implementation project(':capacitor-cordova-android-plugins')
  43. }
  44. apply from: 'capacitor.build.gradle'
  45. try {
  46. def servicesJSON = file('google-services.json')
  47. if (servicesJSON.text) {
  48. apply plugin: 'com.google.gms.google-services'
  49. }
  50. } catch(Exception e) {
  51. logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
  52. }