android - 尝试编译旧项目 Android Studio 时出现 Gradle 错误

标签 android gradle

我正在尝试重新编译一个几个月前运行良好的项目,但我遇到了这样一个 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:

  • 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.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes

我已经从

更新了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/

相关文章:

java - 如何同时运行多个 "for"循环?

Android:检测何时安装了应用程序

java - Gradle 子项目设置、git 子模块

Gradle分发任务输出文件不在ZIP的根目录

spring - 无法解析导入 org.springframework - Java(268435846)

android - 未解析的引用 :test in KoinTest

android - 如何在 Android 上启用/禁用蓝牙硬件初始化日志记录?

Android Instrumentation 测试关注 : debug vs. Release模式

java - 在没有 POM 的情况下生成和使用 gradle 依赖项

java - Eclipse 的 Gradle 集成不断更改 .classpath 文件