Gradle 3.0 - Can't get configuration by name

Hi,

i’m with some trouble running my scripts in the new Android Studio with gradle 3.0.
The problem seems with getting the configuration by name or by position.

Error;
* What went wrong:
Execution failed for task ‘:lib.appbase:generatePomFileForAarPublication’.
> Could not apply withXml() to generated POM
> Configuration with name ‘_releaseImplementation’ not found.

My script:
apply plugin: 'com.android.library’
apply plugin: 'com.jfrog.artifactory’
apply plugin: ‘maven-publish’

android {
compileSdkVersion COMPILE_SDK as int
buildToolsVersion BUILD_TOOLS

defaultConfig {
    minSdkVersion MIN_SDK as int
    targetSdkVersion TARGET_SDK as int
    versionCode BASE_VERSION_CODE as int
    versionName '4.0.33'
}

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

lintOptions {
    disable 'MissingTranslation'
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

}

dependencies {
implementation fileTree(dir: ‘libs’, include: [’*.jar’])

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.2.28'
testImplementation 'org.hamcrest:hamcrest-library:1.3'

implementation 'com.android.support:appcompat-v7:' + SUPPORT_LIBS
implementation 'com.android.support:recyclerview-v7:' + SUPPORT_LIBS
implementation 'com.fasterxml.jackson.core:jackson-core:' + JACKSON_LIB
implementation 'com.fasterxml.jackson.core:jackson-databind:' + JACKSON_LIB
implementation 'com.fasterxml.jackson.core:jackson-annotations:' + JACKSON_LIB
implementation 'com.google.android.gms:play-services-analytics:' + PLAY_SERVICES_LIBS
implementation 'com.google.android.gms:play-services-gcm:' + PLAY_SERVICES_LIBS

implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.squareup.okio:okio:1.13.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.0'

}

publishing {
publications {
aar(MavenPublication) {
groupId "my_group"
version = "${android.defaultConfig.versionName}"
artifactId “com.tandeminnovation.appbase”

        // Tell maven to prepare the generated "*.aar" file for publishing
        artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

        pom.withXml {
            def dependencies = asNode().appendNode('dependencies')
            configurations.getByName("_releaseImplementation").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
                def dependency = dependencies.appendNode('dependency')
                dependency.appendNode('groupId', it.moduleGroup)
                dependency.appendNode('artifactId', it.moduleName)
                dependency.appendNode('version', it.moduleVersion)
            }
        }
    }
}

}

artifactory {
contextUrl = 'repo_url’
publish {
repository {
// The Artifactory repository key to publish to
repoKey = ‘libs-release-local’

        username = artifactory_username
        password = artifactory_password
    }
    defaults {
        // Tell the Artifactory Plugin which artifacts should be published to Artifactory.
        publications('aar')
        publishArtifacts = true

        // Properties to be attached to the published artifacts.
        properties = ['qa.level': 'basic', 'dev.team': 'core']
        // Publish generated POM files to Artifactory (true by default)
        publishPom = true
    }
}

}

PS: I’ve also tried getting config by position (55) but gave illegal access.

Waiting for an advise.

I’ve also tried: configurations.getByName("_releaseImplementation").getResolvedConfiguration().getFirstLevelModuleDependencies().each {

And i’ve printed all available configurations to be sure:
[androidTestAnnotationProcessor,
,
androidTestApi,
,
androidTestCompile,
,
androidTestCompileOnly,
,
androidTestDebugAnnotationProcessor,
,
androidTestDebugApi,
,
androidTestDebugCompile,
,
androidTestDebugCompileOnly,
,
androidTestDebugImplementation,
,
androidTestDebugProvided,
,
androidTestDebugPublish,
,
androidTestDebugRuntimeOnly,
,
androidTestDebugWearApp,
,
androidTestImplementation,
,
androidTestProvided,
,
androidTestPublish,
,
androidTestRuntimeOnly,
,
androidTestWearApp,
,
annotationProcessor,
,
api,
,
compileOnly,
,
debugAnnotationProcessor,
,
debugApi,
,
debugApiElements,
,
debugCompile,
,
debugCompileOnly,
,
debugImplementation,
,
debugProvided,
,
debugPublish,
,
debugRuntimeElements,
,
debugRuntimeOnly,
,
debugWearApp,
,
implementation,
,
provided,
,
publish,
,
releaseAnnotationProcessor,
,
releaseApi,
,
releaseApiElements,
,
releaseCompile,
,
releaseCompileOnly,
,
releaseImplementation,
,
releaseProvided,
,
releasePublish,
,
releaseRuntimeElements,
,
releaseRuntimeOnly,
,
releaseWearApp,
,
runtimeOnly,
,
testAnnotationProcessor,
,
testApi,
,
testCompileOnly,
,
testDebugAnnotationProcessor,
,
testDebugApi,
,
testDebugCompile,
,
testDebugCompileOnly,
,
testDebugImplementation,
,
testDebugProvided,
,
testDebugPublish,
,
testDebugRuntimeOnly,
,
testDebugWearApp,
,
testImplementation,
,
testProvided,
,
testPublish,
,
testReleaseAnnotationProcessor,
,
testReleaseApi,
,
testReleaseCompile,
,
testReleaseCompileOnly,
,
testReleaseImplementation,
,
testReleaseProvided,
,
testReleasePublish,
,
testReleaseRuntimeOnly,
,
testReleaseWearApp,
,
testRuntimeOnly,
,
testWearApp,
,
wearApp]

Hi, i had to downgrade the gradle to 2.3.3 to be able to generate the artifact, did you find any solution to this?

Hello, I hit same issue and fixed it like this:

publishing {
  publications {
    android.libraryVariants.all { variant ->
      aar(MavenPublication) {
        groupId libraryGroupId
        version libraryVersion
        artifactId libraryArtifactId
        artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
        pom.withXml {
          def dependencies = asNode().appendNode('dependencies')
          configurations.getByName(variant.name + "CompileClasspath").allDependencies
              //.findAll { it instanceof ExternalDependency }
              .each {
            def dependency = dependencies.appendNode('dependency')
            dependency.appendNode('groupId', it.group)
            dependency.appendNode('artifactId', it.name)
            dependency.appendNode('version', it.version)
          }
        }
      }
    }
  }

Maybe it can help you too
Roman

Sorry but it did not work for me. CompileClasspath could not to be resolved