|
| 1 | +apply plugin: 'com.android.application' |
| 2 | + |
| 3 | +import java.util.Properties |
| 4 | + |
| 5 | +final Properties keystoreProperties = new Properties() |
| 6 | +final File keystorePropertiesFile = rootProject.file('keystore.properties') |
| 7 | +if (keystorePropertiesFile.exists()) { |
| 8 | + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) |
| 9 | +} |
| 10 | + |
| 11 | +final int appVersionCode = (project.findProperty('APP_VERSION_CODE') ?: '1') as Integer |
| 12 | +final String appVersionName = String.valueOf(project.findProperty('APP_VERSION_NAME') ?: '1.0.0') |
| 13 | +final String appIdBase = String.valueOf(project.findProperty('APP_ID_BASE') ?: 'com.gifts.coupleconnection') |
| 14 | +final String appIdXiaomi = String.valueOf(project.findProperty('APP_ID_XIAOMI') ?: appIdBase + '.mi') |
| 15 | +final String appIdHuawei = String.valueOf(project.findProperty('APP_ID_HUAWEI') ?: appIdBase + '.hw') |
| 16 | + |
| 17 | +android { |
| 18 | + namespace "com.gifts.coupleconnection" |
| 19 | + compileSdk rootProject.ext.compileSdkVersion |
| 20 | + |
| 21 | + defaultConfig { |
| 22 | + applicationId appIdBase |
| 23 | + minSdkVersion rootProject.ext.minSdkVersion |
| 24 | + targetSdkVersion rootProject.ext.targetSdkVersion |
| 25 | + versionCode appVersionCode |
| 26 | + versionName appVersionName |
| 27 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 28 | + |
| 29 | + ndk { |
| 30 | + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' |
| 31 | + } |
| 32 | + |
| 33 | + aaptOptions { |
| 34 | + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. |
| 35 | + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 |
| 36 | + ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + signingConfigs { |
| 41 | + release { |
| 42 | + if (keystorePropertiesFile.exists()) { |
| 43 | + keyAlias keystoreProperties['keyAlias'] |
| 44 | + keyPassword keystoreProperties['keyPassword'] |
| 45 | + storeFile file(keystoreProperties['storeFile']) |
| 46 | + storePassword keystoreProperties['storePassword'] |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + buildTypes { |
| 52 | + debug { |
| 53 | + debuggable true |
| 54 | + } |
| 55 | + release { |
| 56 | + minifyEnabled false |
| 57 | + shrinkResources false |
| 58 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 59 | + if (keystorePropertiesFile.exists()) { |
| 60 | + signingConfig signingConfigs.release |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + flavorDimensions += ["channel"] |
| 66 | + productFlavors { |
| 67 | + official { |
| 68 | + dimension "channel" |
| 69 | + applicationId appIdBase |
| 70 | + resValue 'string', 'app_name', 'Couple Connection' |
| 71 | + manifestPlaceholders = [channelName: 'official'] |
| 72 | + } |
| 73 | + xiaomi { |
| 74 | + dimension "channel" |
| 75 | + applicationId appIdXiaomi |
| 76 | + resValue 'string', 'app_name', 'Couple Connection 小米版' |
| 77 | + versionNameSuffix '-xm' |
| 78 | + manifestPlaceholders = [channelName: 'xiaomi'] |
| 79 | + } |
| 80 | + huawei { |
| 81 | + dimension "channel" |
| 82 | + applicationId appIdHuawei |
| 83 | + resValue 'string', 'app_name', 'Couple Connection 华为版' |
| 84 | + versionNameSuffix '-hw' |
| 85 | + manifestPlaceholders = [channelName: 'huawei'] |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + splits { |
| 90 | + abi { |
| 91 | + enable true |
| 92 | + reset() |
| 93 | + include 'armeabi-v7a', 'arm64-v8a', 'x86_64' |
| 94 | + universalApk true |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | +repositories { |
| 101 | + flatDir { |
| 102 | + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +dependencies { |
| 107 | + implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 108 | + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" |
| 109 | + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" |
| 110 | + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" |
| 111 | + implementation project(':capacitor-android') |
| 112 | + testImplementation "junit:junit:$junitVersion" |
| 113 | + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" |
| 114 | + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" |
| 115 | + implementation project(':capacitor-cordova-android-plugins') |
| 116 | +} |
| 117 | + |
| 118 | +apply from: 'capacitor.build.gradle' |
| 119 | + |
| 120 | +try { |
| 121 | + def servicesJSON = file('google-services.json') |
| 122 | + if (servicesJSON.text) { |
| 123 | + apply plugin: 'com.google.gms.google-services' |
| 124 | + } |
| 125 | +} catch (Exception e) { |
| 126 | + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") |
| 127 | +} |
0 commit comments