本文介绍了在升级到gradle时获取应用程序build.gradle同步问题3. +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新一个项目,其中包含许多不同的库和风格。我能够解决项目中的所有库,但在更新应用程序build.gradle时遇到问题。下面是错误和gradle的。我显然误解了文档,找不到正确的解决方案。如何在应用程序build.gradle级别解决此同步问题?

I am in the process of updating a project with many different libs and flavors across all of them. I was able to resolve all of the libs in the project but I am facing an issue while updating the app build.gradle. Below is the error and the gradle's. I am obviously misunderstanding the docs and cannot find the correct solution. How do I solve this sync issue in the app build.gradle level?

错误

Error

Unable to resolve dependency for ':app@magicDebug/compileClasspath': Could not resolve project :vnfmdata.

Could not resolve project :vnfmdata.
Required by:
    project :app
 > Project :app declares a dependency from configuration 'implementation' to configuration 'regularDebug' which is not declared in the descriptor for project :vnfmdata.

应用程序build.gradle

android {
    ...
    flavorDimensions flavor.default
    productFlavors {
        ...
        magic {
            ...
            flavorDimensions flavor.default
            // missingDimensionStrategy flavor.regular, flavor.regular
            // matchingFallbacks = [flavor.regular]
            dependencies {
                ...
                implementation project(':vnfmdata')
                // implementation project(path: ':vnfmdata', configuration: 'regularDebug') // pre gradle 3.0
                ...
            }
        }
    }
}

___ gradle同步的两个库很好___

vnfmdata build.gradle

vnfmdata build.gradle

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

dependencies {
    ...
    implementation project(':vnlocationservice')
    ...
}

vnlocationservice build.gradle

vnlocationservice build.gradle

android {
    ...
    /** Flavors **/
    flavorDimensions flavor.meridian, flavor.no_meridian
    productFlavors {
        no_meridian {
            dimension flavor.no_meridian
        }
        meridian {
            dimension flavor.meridian
            dependencies {
                implementation project(':third:Sas-Android')
                implementation deps.support.compat_v26
                implementation deps.play.ads
                implementation deps.play.location
                implementation deps.localytics
                implementation 'com.arubanetworks.meridian:meridian:+@aar'
            }
        }
    }
    buildTypes {
        release {}
    }
    ...
}

dependencies {
    ...
}


推荐答案

你的模块目前没有维度,所以你应该只使用一个维度,就像你应用程序的build.gradle flavorDimensions flavor.default

Your modules currently doesn't have dimensions, so you should only use one dimension, like into you app's build.gradle flavorDimensions flavor.default.

(见第是的一部分,并查看是什么)

(See this part of the documentation and see what are the multiple outputs when you use flavorDimensions.)

vnfmdata

...
//With only one dimension, you can omit 'dimension' into your flavors
flavorDimensions flavor.default

productFlavors {
    regular {
        dimension flavor.default
        ...
    }
    no_meridian {
        dimension flavor.default
    }
}

vnlocationservice

...
//With only one dimension, you can omit 'dimension' into your flavors
flavorDimensions flavor.default

productFlavors {
    no_meridian {
        dimension flavor.default
    }
    meridian {
        dimension flavor.default
        dependencies {
            ...
        }
    }
}

这篇关于在升级到gradle时获取应用程序build.gradle同步问题3. +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 20:42