Getting app build.gradle Sync issue while upgradin

2019-03-02 10:03发布

问题:

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.

App 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
                ...
            }
        }
    }
}

___The two libs below gradle's sync fine ___

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

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 {
    ...
}

回答1:

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 {
            ...
        }
    }
}