1

Unable to resolve dependency for ':business:diary@debug/compileClasspath': Could not resolve project :fun:push.

Could not resolve project :fun:push. Required by: project :business:diary

Unable to find a matching configuration of project :fun:push: - Configuration 'jpushDebugApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'jpushDebug' but wasn't required. - Required map 'amap' but no value provided. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Required push 'jpush' and found compatible value 'jpush'. - Configuration 'jpushDebugMetadataElements': - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value

I have already read Migrate to Android Plugin for Gradle 3.0.0, but i add missingDimensionStrategy location not app module build.gradle file. Created a new file config.gradle as:

project.ext {
setDefaultConfig = {
    extension ->
        extension.android {
            compileSdkVersion 25
            buildToolsVersion "25.0.3"
            defaultConfig {
                minSdkVersion 16
                targetSdkVersion 22
                versionCode 1
                versionName "1.0"
                multiDexEnabled true
                missingDimensionStrategy 'map', mapImplFlavor//add to here
                missingDimensionStrategy 'push', pushImplFlavor

                ndk {
                    abiFilters 'armeabi', 'x86','armeabi-v7a'
                }
                javaCompileOptions {
                    annotationProcessorOptions {
                        arguments = [moduleName: project.getName()]
                    }
                }
            }
        }
        println("extension : " + extension.android.defaultConfig.getMissingDimensionStrategies().toString())
}

Also, for all module build.gradle imported this file:

apply from: "${rootProject.rootDir}/config.gradle"
apply plugin: AutoBuild
android {
    project.ext.setDefaultConfig project  //import above code
    resourcePrefix "diary_" 
`````

Finally when I use set AutoBuild plugin to automatically apply com.android.application or com.android.library plugin (That is, not directly in the build.gradle file)and other operation. This problem appears when I Sync or Clean project, but build is a success.

I found that AutoBuild plugin is running first,Then it's config.gradle, I also added inject missingDimensionStrategy in AutoBuild plugin, but it doesn't resolve. Please help!

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Void Young
  • 61
  • 1
  • 7
  • Can you please post the `settings.gradle` file of your main project? – sud007 Sep 19 '17 at 10:41
  • settings.gradle:`include ':app', ':buildsrc', ':business:diary', ':business:memberCenter', ':business:mall', ':fun:push', ':fun:map', ':baseLib:core', ':baseLib:fecCommon'` – Void Young Sep 19 '17 at 13:12
  • what's your gradle version? look at [this](https://stackoverflow.com/questions/44114044/flavordimensions-gradle-error-android-studio-3-0-canary-1), it may help you. – Mehran Zamani Sep 20 '17 at 04:07
  • Okay out of those module names which are mentioned in your `settings.gradle` have you deleted any one? For eg. if you have deleted `:fun:map` from the project structure but forgot to delete `:fun:map` from the `settings.gradle` file. Can you please check that? – sud007 Sep 20 '17 at 05:41
  • no,I didn't delete any one. I think `com.android.builder.core.DefaultProductFlavor#missingDimensionStrategy(java.lang.String, java.lang.String)`perform need a explicit apply com.android.application or com.android.library in build.gradle file – Void Young Sep 20 '17 at 08:21

2 Answers2

0

Finally I added the following code in module build.gradlefile resolve this problem:

apply from: "${rootProject.rootDir}/config.gradle"

if (!gradle.startParameter.taskNames.toString().toUpperCase().contains('ASSEMBLE'))    {
    apply plugin: 'com.android.application'
} else {
    apply plugin: com.fec.buildgradle.AutoBuild 
}

android {
    project.ext.setDefaultConfig project
    resourcePrefix "diary_" 
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

 // in runtime following code is invalid just for sync and clean
    if (!gradle.startParameter.taskNames.toString().toUpperCase().contains('ASSEMBLE')) {
        sourceSets {
            main {
                manifest.srcFile "src/main/runAlone/AndroidManifest.xml"
            }
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project.ext.dependencies["constraint-layout"]
    annotationProcessor project.ext.dependencies["arouterCompiler"]
    api project(':baseLib:core')
}
mhenryk
  • 551
  • 5
  • 13
Void Young
  • 61
  • 1
  • 7
0

It gave me the same error and I tried all the suggestions mentioned here, but it didn't work. Then I just created another fresh project and it worked fine. I know this is not the solution but just a work around.

Manpreet
  • 570
  • 5
  • 20