webdevqa.jp.net

'compileClasspath'という名前の構成が見つかりません

com.Android.tools.build:gradle:3.0.0-beta3とGradle4.1に移行すると、次のエラーが表示されます。

原因:org.gradle.api.artifacts.UnknownConfigurationException:「compileClasspath」という名前の構成が見つかりません。 org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.createNotFoundException(DefaultConfigurationContainer.Java:123)at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.Java:229)at org.gradle.api.internal .artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.Java:113)at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.getByName(DefaultConfigurationContainer.Java:48)at com.Android.build.gradle.internal.LintGradleProject $ ProjectSearch.getProject(LintGradleProject.Java:884)at com.Android.build.gradle.internal.LintGradleProject $ ProjectSearch.getProject(LintGradleProject.Java:996)at com.Android.build.gradle.internal.LintGradleProject $ ProjectSearch.getProject (LintGradleProject.Java:785)at com.Android.build.gradle.internal.LintGradleClient.createLintRequest(LintGradleClient.Java:193)at com.Android.tools.lint.LintCliClient.run(LintCli Client.Java:151)at com.Android.build.gradle.internal.LintGradleClient.run(LintGradleClient.Java:209)at com.Android.build.gradle.tasks.Lint.runLint(Lint.Java:365)at com .Android.build.gradle.tasks.Lint.lintSingleVariant(Lint.Java:335)


これが私のディレクトリ構造です:

Android-db
  /db
    /build.gradle
  settings.gradle
  /Android-common
    build.gradle
    /common
        build.gradle

Android-db/db/build.gradleは次のとおりです。

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.0-beta3'
    }
}

apply plugin: 'com.Android.library'

Android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }
}

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    google()
}

def jenkinsBuildNumber = {
    System.getenv().BUILD_NUMBER?.toInteger() ?: 999999
}

// Change this when we upgrade the library version
def buildVersion = {
    '1.0' + "." + jenkinsBuildNumber()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
    implementation project(path: ':Android-common:common', configuration: 'default')

    androidTestImplementation('com.Android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.Android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    testImplementation "org.robolectric:robolectric:3.0"
    implementation 'com.annimon:stream:1.1.5'
    implementation 'com.jakewharton.timber:timber:4.5.1'
    implementation 'com.google.code.gson:gson:2.4'
    implementation 'com.squareup.retrofit:retrofit:1.9.0'
} 

Android-db/Android-common/common/build.gradleは次のとおりです。

buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.0-beta3'
    }
}

apply plugin: 'com.Android.library'

Android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'

    defaultConfig {
        minSdkVersion 15
        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
    }

    dataBinding {
        enabled = true
    }
}

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    google()
}


def jenkinsBuildNumber = {
    System.getenv().BUILD_NUMBER?.toInteger() ?: 999999
}

// Change this when we upgrade the library version
def buildVersion = {
    '1.0' + "." + jenkinsBuildNumber()
}

ext {
    supportLibVersion = '25.3.1'
    playServicesVersion = '10.2.6'
}

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

    compile "com.Android.support:support-v4:${supportLibVersion}"
    compile "com.Android.support:appcompat-v7:${supportLibVersion}"
    compile "com.google.Android.gms:play-services-maps:${playServicesVersion}"
    compile 'com.Android.databinding:library:1.3.1'
    compile 'com.Android.databinding:adapters:1.3.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'org.jsoup:jsoup:1.9.2'
    compile 'com.jakewharton.timber:timber:4.5.1'
    compile 'com.squareup:seismic:1.0.2'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.google.code.gson:gson:2.4'

    compile "com.Android.support:recyclerview-v7:${supportLibVersion}"
    compile 'javax.inject:javax.inject:[email protected]'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxjava:2.0.1'


    // Unit testing dependencies
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    // Set this dependency if you want to use the Hamcrest matcher library
    //androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
    // more stuff, e.g., Mockito
    testCompile "org.robolectric:robolectric:3.3"
}
12
Yu Chen

今日、私は同じ問題を解決しました!私は解決策を見つけるために1週間以上を費やしました。要するに、Gradle用のLint-pluginは、暗黙のうちに次のセクションがあることを前提としています。

buildscript {
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath "com.Android.tools.build:gradle:$gradlePluginVersion"
    }
}

ルートレベルでbuild.gradleファイル。その共通セクションをスクリプトからルートレベルのスクリプトに移動するだけです。

8
Daniil Popov