gpt4 book ai didi

android - 未找到名称为 'compileClasspath' 的配置

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:43:31 25 4
gpt4 key购买 nike

当我迁移到 com.android.tools.build:gradle:3.0.0-beta3 和 Gradle 4.1 时,我看到以下错误:

Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'compileClasspath' not found. at 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(LintCliClient.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:1@jar'
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"
}

最佳答案

今天我解决了同样的问题!我花了一个多星期试图找到解决方案。简而言之,Gradle 的 Lint 插件隐含地假设您有以下部分

buildscript {
repositories {
jcenter()
google()
}

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

在您的根级 build.gradle 文件中。只需将该公共(public)部分从您的脚本直接移动到根级脚本即可。

关于android - 未找到名称为 'compileClasspath' 的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45966028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com