| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- apply plugin: 'com.android.application'
- def fmodeJpushEnabled = providers.gradleProperty('fmodeJpushEnabled').getOrElse('false').toBoolean()
- def fmodeJpushAppKey = providers.environmentVariable('JPUSH_APPKEY').getOrElse('')
- // 厂商通道开关(2026-11-21):默认关。开启前必须已打包对应厂商 AAR,否则初始化崩溃。
- def fmodeVendorPushEnabled = providers.environmentVariable('FMODE_VENDOR_PUSH').getOrElse('false').toBoolean()
- android {
- namespace = "cn.fmode.app"
- compileSdk = rootProject.ext.compileSdkVersion
- defaultConfig {
- applicationId "cn.fmode.app"
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- buildConfigField 'boolean', 'JPUSH_ENABLED', fmodeJpushEnabled.toString()
- // 厂商通道:JPushSdk 读取此值决定 setThirdPushEnable(true/false)
- buildConfigField 'boolean', 'JPUSH_VENDOR_ENABLED', (fmodeJpushEnabled && fmodeVendorPushEnabled).toString()
- /*
- * 厂商通道占位符:必须**始终有值**,否则 Manifest 里的 ${...} 解析失败。
- * 未开启厂商通道时填空串 —— 极光 SDK 见到空值会跳过该厂商,
- * 不会因为占位符缺失而崩溃。
- */
- manifestPlaceholders += [
- JPUSH_XIAOMI_APPID : providers.environmentVariable('XIAOMI_APPID').getOrElse(''),
- JPUSH_XIAOMI_APPKEY : providers.environmentVariable('XIAOMI_APPKEY').getOrElse(''),
- JPUSH_HUAWEI_APPID : providers.environmentVariable('HUAWEI_APPID').getOrElse(''),
- JPUSH_OPPO_APPKEY : providers.environmentVariable('OPPO_APPKEY').getOrElse(''),
- JPUSH_OPPO_APPID : providers.environmentVariable('OPPO_APPID').getOrElse(''),
- JPUSH_OPPO_APPSECRET : providers.environmentVariable('OPPO_APPSECRET').getOrElse(''),
- JPUSH_VIVO_APPKEY : providers.environmentVariable('VIVO_APPKEY').getOrElse(''),
- JPUSH_VIVO_APPID : providers.environmentVariable('VIVO_APPID').getOrElse(''),
- JPUSH_HONOR_APPID : providers.environmentVariable('HONOR_APPID').getOrElse(''),
- ]
- manifestPlaceholders += [JPUSH_APPKEY: fmodeJpushAppKey, JPUSH_CHANNEL: 'fmode', JPUSH_ENABLED: fmodeJpushEnabled.toString()]
- aaptOptions {
- // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
- // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
- ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
- }
- }
- buildFeatures {
- buildConfig = true
- }
- if (!fmodeJpushEnabled) {
- sourceSets.main.java {
- exclude '**/JPushSdk.java', '**/JPushReceiver.java', '**/JPushService.java', '**/JPushClickActivity.java'
- }
- }
- if (fmodeJpushEnabled && file('src/jpush/AndroidManifest.xml').exists()) {
- sourceSets.debug.manifest.srcFile 'src/jpush/AndroidManifest.xml'
- sourceSets.release.manifest.srcFile 'src/jpush/AndroidManifest.xml'
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- repositories {
- if (fmodeJpushEnabled) {
- maven {
- url 'https://maven.jiguang.cn/nexus/content/repositories/releases/'
- content { includeGroup 'cn.jiguang.sdk' }
- }
- }
- flatDir{
- dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
- }
- }
- dependencies {
- if (fmodeJpushEnabled) {
- implementation('cn.jiguang.sdk:jpush:6.3.1') {
- exclude group: 'cn.jiguang.sdk', module: 'jcore'
- }
- implementation 'cn.jiguang.sdk:jcore:5.6.0'
- }
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
- implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
- implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
- implementation project(':capacitor-android')
- testImplementation "junit:junit:$junitVersion"
- androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
- androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
- implementation project(':capacitor-cordova-android-plugins')
- }
- apply from: 'capacitor.build.gradle'
- try {
- def servicesJSON = file('google-services.json')
- if (servicesJSON.text) {
- apply plugin: 'com.google.gms.google-services'
- }
- } catch(Exception e) {
- logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
- }
|