gpt4 book ai didi

android - 仅向特定 flavor 添加依赖项 - Android Studio

转载 作者:太空狗 更新时间:2023-10-29 16:14:45 25 4
gpt4 key购买 nike

我的项目有免费和付费版本,

免费版使用 Admob 服务,付费版没有任何广告。 我怎样才能删除付费版本的依赖

这是我的build.gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.udacity.gradle.builditbigger"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
testApplicationId"com.udacity.gradle.builditbigger.tests"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors{
free{
applicationId"com.udacity.gradle.builditbigger.flavours.free"
}
paid{

applicationId"com.udacity.gradle.builditbigger.flavours.paid"
}


}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Added for AdMob

compile project(':mylibrary')
compile project(path: ':endpoint-backend', configuration: 'android-endpoints')
compile 'com.android.support:appcompat-v7:22.2.0'


compile 'com.google.android.gms:play-services:7.5.0'


}

我希望依赖项编译 'com.google.android.gms:play-services:7.5.0' 仅适用于免费版本,而不适用于付费版本。

最佳答案

要为不同的构建类型或风格添加不同的依赖项,您可以使用它

dependencies {
releaseCompile
debugCompile
flavor1Compile
flavor1DebugCompile
}

在你的情况下:

 dependencies {
freeCompile 'com.google.android.gms:play-services:7.5.0'
}

此外,如果您需要 olny Admob,您应该使用此依赖项而不是完整的播放服务。

   compile 'com.google.android.gms:play-services-ads:7.8.0'

关于android - 仅向特定 flavor 添加依赖项 - Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32409993/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com