赞
踩
因为umeng违反了Google Play的政策规定,所以需要对于gp版本排掉umeng相关的东西
signingConfigs { china { storeFile file('debug.keystore') storePassword "" keyAlias '' keyPassword "" } overseas { storeFile file('googlePlay.keystore') storePassword "" keyAlias '' keyPassword "" } } buildTypes { release { minifyEnabled false shrinkResources false } debug { minifyEnabled false shrinkResources false } } // 此处为风格,也就是拆分flavor,我只设置了region。可以设置多个,比如"version", "region" flavorDimensions "region" // 此处设置了china和overseas版本 productFlavors { china { dimension "region" proguardFiles 'proguard-rules.pro' signingConfig signingConfigs.china buildConfigField "boolean", "isGooglePlayApp", "false" } overseas { dimension "region" proguardFiles 'proguard-rules.pro' signingConfig signingConfigs.overseas buildConfigField "boolean", "isGooglePlayApp", "true" } } // 这里的china和overseas实际上就是指定资源文件和源码位置 sourceSets { main { jniLibs.srcDirs = ['libs'] assets.srcDirs = ['src/main/assets', 'assets/'] java { srcDir 'src/main/java' } } china { java.srcDirs = ['src/china/java'] res.srcDirs = ['src/china/res'] } overseas { java.srcDirs = ['src/overseas/java'] res.srcDirs = ['src/overseas/res'] } } // 此处就是 dependencies { implementation "androidx.multidex:multidex:2.0.1" implementation fileTree(include: ['*.aar', '*.jar'], dir: 'libs') // 此处就是根据不同的flavor设置不同的依赖 productFlavors { china { dimension "region" // 国内依赖 // release umeng releaseApi 'com.umeng.umsdk:common:9.5.6' releaseApi 'com.umeng.umsdk:asms:1.6.3' releaseApi 'com.umeng.umsdk:push:6.5.8' releaseApi 'com.umeng.umsdk:xiaomi-umengaccs:1.3.2' releaseApi 'com.umeng.umsdk:xiaomi-push:5.1.2' releaseApi 'com.umeng.umsdk:huawei-umengaccs:1.4.1' releaseApi 'com.huawei.hms:push:6.7.0.300' // debug umeng debugApi 'com.umeng.umsdk:common:9.5.6' debugApi 'com.umeng.umsdk:asms:1.6.3' debugApi 'com.umeng.umsdk:push:6.5.8' debugApi 'com.umeng.umsdk:xiaomi-umengaccs:1.3.2' debugApi 'com.umeng.umsdk:xiaomi-push:5.1.2' debugApi 'com.umeng.umsdk:huawei-umengaccs:1.4.1' debugApi 'com.huawei.hms:push:6.7.0.300' } overseas { dimension "region" // 国外依赖 releaseApi platform('com.google.firebase:firebase-bom:29.0.0') releaseApi 'com.google.firebase:firebase-messaging' releaseApi 'com.google.firebase:firebase-analytics' } } }
src ├── main │ ├── java │ │ └── xxx │ ├── res │ │ ├── xxx ├── china │ ├── java │ │ └── xxx │ ├── res │ │ ├── xxx └── overseas ├── java │ └── xxx ├── res │ ├── xxx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。