Gradle - 无法创建Tooling API实现的实例

时间:2016-01-04 20:18:31

标签: android android-studio gradle android-gradle gradle-tooling-api

我尝试从GitHub导入项目并在Android Studio上构建/运行它。我收到以下错误:

  

"错误:无法创建Tooling API实现的实例   使用指定的Gradle分布   ' https://services.gradle.org/distributions/gradle-2.4-all.zip'"

我尝试了以下内容:

  1. 使缓存无效并重新启动
  2. 将gradle-wrapper / properties中的distributionURL更改为2.5等。
  3. 删除build.gradle并重新启动
  4. 这些是我在stackoverflow上从其他几篇文章中得到的想法,所以我无法解释为什么我尝试这些。 (我对Android Studio非常陌生)。

    我的build.gradle文件如下所示:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.5.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        } }
    
    allprojects {
        repositories {
            jcenter()
        } }
    
    task clean(type: Delete) {
        delete rootProject.buildDir }
    

5 个答案:

答案 0 :(得分:0)

请改变

   distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

    distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

然后改变

  classpath 'com.android.tools.build:gradle:1.5.1'

 classpath 'com.android.tools.build:gradle:2.0.0-alpha3' 

它应该有用。

答案 1 :(得分:0)

对我来说,我认为这是许可问题。从Eclipse,我也遇到过同样的问题。在我的gradle安装路径(即/ opt / gradle)上,将其chmod设置为777。以便其他工具可以访问它。运行以下2个命令-

cd /opt
sudo chmod 777 -R gradle

答案 2 :(得分:0)

Java版本> 9和Gradle版本> = 5.0.0有一些代码中断更改。这里是使用Eclipse解决它们的方法。在AndroidStudio中应该类似。

  • 从其分发站点安装最新版本的gradle (“ https://services.gradle.org/distributions/”)和 将其解压缩到您的PC上。
  • 在eclipse中导入gradle项目时,选择选项“本地安装 目录”,然后指向解压gradle的文件夹。
  • (奖励)如果它是一个LibGDX项目,则还需要在桌面中更改以下内容 由于gradle版本<5.0.0和> = 5.0.0之间的代码中断更改而导致生成文件。 将“ sourceSets.main.output.classesDir”更改为“ sourceSets.main.output.classesDirs”。

这对我有用,我在运行Eclipse 2018-12时在Windows 10上将LibGDX与Java 11和Gradle 5.2.1结合使用。

答案 3 :(得分:0)

我遇到了类似的问题,更新了 const orderSchema = mongoose.Schema({ id: mongoose.Schema.Types.ObjectId, product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true }, quantity: { type: Number, default: 1 } }); const productSchema = mongoose.Schema({ _id: mongoose.Schema.Types.ObjectId, name: { type: String, required: true }, price: { type: Number, required: true }, productImage: { type: String } }); 中的Gradle版本就解决了。

distributionUrl字段位于此目录下:

distributionUrl

答案 4 :(得分:0)

尝试删除 ~/.gradle/wrapper/dists 中的文件夹 gradle-2.4-all