我正在尝试重新编译一个几个月前运行良好的项目,但我遇到了这样一个 gradle 错误:
Error:(1, 0) Unable to find method
'org.gradle.api.Project.getPluginManager()Lorg/gradle/api/plugins/PluginManager;'. Possible causes for this unexpected error include:In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes
- Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
- The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
- 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.
我已经从
更新了build.gradle
文件(项目)中的gradle版本
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
到
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
我听从了 AS 的建议,但没有走运。
你能给个建议吗?
我的 build.gradle
文件(app)是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 14
buildToolsVersion "22.0.1"
defaultConfig {
applicationId 'com.aabcdata.learn.german.hd'
minSdkVersion 14
targetSdkVersion 14
versionCode 6
versionName '1.5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile files('libs/FlurryAnalytics_3.3.2.jar')
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile files('libs/AppTracker.jar')
compile files('libs/presage-lib-1.6.0.jar')
}
我也做了一个 Invalidate Cache/Restart
最佳答案
我在一个非常古老的项目中也遇到过这个问题。您需要在 gradle-wrapper.properties
文件中升级 gradle 分发版本。我将它从版本 2.2.1
更改为 4.1
。
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
关于android - 尝试编译旧项目 Android Studio 时出现 Gradle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48125948/