build.gradle 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. apply plugin: 'com.android.application'
  2. android {
  3. namespace "com.example.app"
  4. compileSdk rootProject.ext.compileSdkVersion
  5. defaultConfig {
  6. applicationId "com.example.app"
  7. minSdkVersion rootProject.ext.minSdkVersion
  8. targetSdkVersion rootProject.ext.targetSdkVersion
  9. versionCode 1
  10. versionName "1.0"
  11. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  12. aaptOptions {
  13. // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
  14. // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
  15. ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
  16. }
  17. }
  18. compileOptions {
  19. sourceCompatibility JavaVersion.VERSION_17
  20. targetCompatibility JavaVersion.VERSION_17
  21. }
  22. buildTypes {
  23. release {
  24. minifyEnabled false
  25. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  26. }
  27. }
  28. }
  29. repositories {
  30. flatDir{
  31. dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
  32. }
  33. }
  34. dependencies {
  35. implementation fileTree(include: ['*.jar'], dir: 'libs')
  36. implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
  37. implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
  38. implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
  39. implementation project(':capacitor-android')
  40. testImplementation "junit:junit:$junitVersion"
  41. androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
  42. androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
  43. implementation project(':capacitor-cordova-android-plugins')
  44. // 排除旧版本的 Kotlin JDK7/JDK8 标准库(Kotlin 1.8+ 已合并到主库)
  45. configurations.all {
  46. exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
  47. exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
  48. }
  49. }
  50. apply from: 'capacitor.build.gradle'
  51. try {
  52. def servicesJSON = file('google-services.json')
  53. if (servicesJSON.text) {
  54. apply plugin: 'com.google.gms.google-services'
  55. }
  56. } catch(Exception e) {
  57. logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
  58. }