gpt4 book ai didi

android - 错误:(2,0)无法找到方法'org.gradle.api.internal.file.DefaultSourceDirectorySet

转载 作者:行者123 更新时间:2023-12-02 13:39:01 24 4
gpt4 key购买 nike

我最近将我的android studio升级到3.0.1,当我尝试创建新项目时,出现以下错误我的代码在较旧版本上运行良好,我还升级了Gradle插件

错误

Error:(2, 0) Unable to find method 

'org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;)V'. Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) <a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. <a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

构建Gradle文件
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.myapplication"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:cardview-v7:26.1.0'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
}

最佳答案

尝试

./gradlew clean
./gradlew assemble

看看是否有帮助?另外,在您的依赖项中,请确保将Gradt 3推荐的 compile更改为 implementation

关于android - 错误:(2,0)无法找到方法'org.gradle.api.internal.file.DefaultSourceDirectorySet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47542735/

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