本文介绍了该项目可能正在使用不包含“compileSdkVersion()"方法的 Gradle 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试运行最初在 Eclipse ADT 上创建的项目时遇到了这个问题.

I'm facing this issue when trying to run a project originally made on Eclipse ADT.

Error:(17, 0) Gradle DSL method not found: 'compileSdkVersion()'
Possible causes:<ul><li>The project 'TaxiAndroidOpen-master' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

我已经将其转换为 Android Studio gradle 系统.

I already converted this to Android Studio gradle system.

但是我不能运行它,也不能编译它,因为这个错误,这里是生成的gradle:

But I cannot run it, nor compile it, because of this error, here's the gradle generated:

// 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.0.0'
   }
}
allprojects {
repositories {
    jcenter()
   }
}

ext {
compileSdkVersion 17
buildToolsVersion '18.1.0'
}
dependencies {
}

我在 SO 上发现了一些其他帖子,有类似的错误,但没有人有这个特定的错误.

I've found some other posts here on SO, with similar errors, but no one has this specific one.

我使用的是 Android Studio 1.0.2、x86.

I'm using Android Studio 1.0.2, x86.

有人可以解释一下吗?

提前致谢!

编辑

更新了 build.gradle:

Updated build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 17
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.opentaxi.android"
    minSdkVersion 9
    targetSdkVersion 19
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile project(':comtaxibulgariamap_mapsforge_044201406271417533')
compile files('libs/littlefluffylocationlibrary_r15.jar')
}

推荐答案

您的应用程序模块的 build.gradle 文件应如下所示.

Your application module's build.gradle file should look like this.

apply plugin: 'com.android.application'

android {
   compileSdkVersion 17
   buildToolsVersion "21.1.2"

defaultConfig {
     applicationId "com.opentaxi.android"
     minSdkVersion 9
     targetSdkVersion 19
  }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {

    compile project(':comtaxibulgariamap_mapsforge_044201406271417533')
    compile fileTree(include: ['*.jar'], dir: 'libs')
}

并从您的主 bu​​ild.gradle(在应用程序的根目录中)中删除这些行(如果它在您发布时存在).

And remove these lines from your main build.gradle (in application's root) if it exists as you posted.

  ext {
      compileSdkVersion 17
      buildToolsVersion '18.1.0'
    }
    dependencies {
    }

这篇关于该项目可能正在使用不包含“compileSdkVersion()"方法的 Gradle 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:46