gpt4 book ai didi

android - 使用编译不同风格的库迁移到 gradle 3.+

转载 作者:行者123 更新时间:2023-11-30 00:02:31 25 4
gpt4 key购买 nike

我有一个非常复杂的项目,其中包含许多相互依赖的库。我已经浏览了所有文档和视频,但没有任何内容指向正确的方向来编译基于 flavor 的库。我对项目方面感到困惑。如果有人能指出我正确的方向来更新编译以实现,那就太好了。如何直接替换配置:以匹配口味?

这里是两个 gradle 的例子。

vnfmdata

android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools

defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

publishNonDefault true
flavorDimensions flavor.default
productFlavors {
regular {}
no_meridian {}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

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

regularCompile project(':vncore')
regularCompile project(path: ':vnlocationservice', configuration: 'meridianDebug')

no_meridianCompile project(':vncore')
no_meridianCompile project(path: ':vnlocationservice', configuration: 'no_meridianDebug')
}

vnlocationservices

android {
compileSdkVersion build_versions.compile_sdk
buildToolsVersion build_versions.build_tools

defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

publishNonDefault true
productFlavors {
no_meridian {}
meridian {}
}

buildTypes {
release {
//minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile deps.support.app_compat

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'

no_meridianCompile project(':vncore')

meridianCompile project(':vncore')
meridianCompile project(':third:Sas-Android')

//Localytics
meridianCompile deps.support.compat_v26
meridianCompile deps.play.ads
meridianCompile deps.play.location
meridianCompile deps.localytics
///////////////////

meridianCompile 'com.arubanetworks.meridian:meridian:+@aar'

}

最佳答案

编辑:我发现将依赖项节点添加到一种风格中会影响另一种风格。相反,最好使用 <flavor's name>Implementation .


正如您所说,您可能进入了 Migration Guide resolve matching errors .

vnfmdata

此处的更改位于 flavor 以及依赖项如何更改:

android {
...
productFlavors {
regular {
// Forces regular's flavor to point on LocationService meridian's flavor
// because their flavors' name are different
matchingFallbacks = ["meridian"]
}
no_meridian {
// Will automatically point on LocationService no_meridian's flavor
// because they both have the same name
}
}
...
}

dependencies {
// We used the flavors' matching feature
// so gradle knows that if you select regular, you wants the meridian flavor on these 2 projects
implementation project (":vncore")
implementation project (":vnlocationservice")

}

vnlocationservices

在这里,我们将了解如何声明仅由一种风格使用的依赖项。

android {
...
productFlavors {
meridian {}
no_meridian {}
}
...
}

dependencies {
implementation project (":vncore")

meridianImplementation project(':third:Sas-Android')

//Localytics
meridianImplementation deps.support.compat_v26
meridianImplementation deps.play.ads
meridianImplementation deps.play.location
meridianImplementation deps.localytics
///////////////////

meridianImplementation 'com.arubanetworks.meridian:meridian:+@aar'

}
}

关于android - 使用编译不同风格的库迁移到 gradle 3.+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49657063/

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