android– 找不到Gradle DSL方法:将模块导入项目后’compileSdkVersion()’

android– 找不到Gradle DSL方法:将模块导入项目后’compileSdkVersion()’,第1张

概述我在AndroidStudio中有一个项目.我需要在这个项目中导入一个模块:https://github.com/square/android-times-square/这个包里有一个图书馆和一个样本.我导入了它们.我下载.zip并在AndroidStudio中执行文件–>新–>导入模块然后我得到了graddle错误:Error:(16,0)GradleDSL

我在Android Studio中有一个项目.我需要在这个项目中导入一个模块:https://github.com/square/android-times-square/
这个包里有一个图书馆和一个样本.我导入了它们.
我下载.zip并在AndroID Studio中执行文件 – >新 – >导入模块
然后我得到了graddle错误:

Error:(16, 0) Gradle DSL method not found: 'compileSdkVersion()'Possible causes:The project 'MyProject' may be using a version of the AndroID Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).Upgrade plugin to version 2.3.3 and sync project. The project 'MyProject' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file. The build file may be missing a Gradle plugin.Apply Gradle plugin

我已单击此错误消息中列出的所有链接.但它没有帮助.
gradle脚本有什么问题?
我不明白为什么有这么多的gradle文件和我需要修复的文件(((

build.gradle(MyProject)

buildscript {    repositorIEs {        jcenter()    }    dependencIEs {        classpath 'com.androID.tools.build:gradle:2.3.3'        // NOTE: Do not place your application dependencIEs here; they belong        // in the indivIDual module build.gradle files    }}ext {    compileSdkVersion 25    buildToolsversion "25.0.2"    minSdkVersion 16    targetSdkVersion 25}allprojects {    repositorIEs {        jcenter()    }}task clean(type: Delete) {    delete rootProject.buildDir}

build.gradle(库)

apply plugin: 'com.androID.library'apply plugin: 'checkstyle'task checkstyle(type: Checkstyle) {  configfile rootProject.file('checkstyle.xml')  source 'src/main/java'  ignoreFailures false  showViolations true  include '**/*.java'  classpath = files()}afterEvaluate {  if (project.tasks.findByname('check')) {    check.dependsOn('checkstyle')  }}androID {  compileSdkVersion rootProject.ext.compileSdkVersion  buildToolsversion rootProject.ext.buildToolsversion  defaultConfig {    minSdkVersion rootProject.ext.minSdkVersion  }  lintoptions {    warning 'MissingTranslation'    textReport true    textoutput 'stdout'  }}dependencIEs {  testCompile deps.festandroID  testCompile deps.junit  testCompile deps.robolectric  testCompile deps.intellijannotations}apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

build.gradle(样本)

apply plugin: 'com.androID.application'androID {  compileSdkVersion rootProject.ext.compileSdkVersion  buildToolsversion rootProject.ext.buildToolsversion  compileOptions {    sourceCompatibility rootProject.ext.sourceCompatibilityVersion    targetCompatibility rootProject.ext.targetCompatibilityVersion  }  defaultConfig {    applicationID 'com.squareup.timessquare.sample'    minSdkVersion rootProject.ext.minSdkVersion    targetSdkVersion rootProject.ext.targetSdkVersion    versionCode 1    versionname '1.0.0'  }  lintoptions {    disable 'MissingTranslation'  }}dependencIEs {  compile project(':library')}

build.gradle(module:app)

apply plugin: 'com.androID.application'androID {    compileSdkVersion 25    buildToolsversion "25.0.2"    defaultConfig {        applicationID "com.myproject.myproject2"        minSdkVersion 16        targetSdkVersion 25        versionCode 1        versionname "1.0"        testInstrumentationRunner "androID.support.test.runner.AndroIDJUnitRunner"    }    buildTypes {        release {            MinifyEnabled false            proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    compile filetree(dir: 'libs', include: ['*.jar'])    androIDTestCompile('com.androID.support.test.espresso:espresso-core:2.2.2', {        exclude group: 'com.androID.support', module: 'support-annotations'    })    compile 'com.androID.support:appcompat-v7:25.3.1'    compile 'com.androID.support:design:25.3.1'    compile 'com.androID.support.constraint:constraint-layout:1.0.2'    compile 'com.androID.support:support-v4:25.3.1'    testCompile 'junit:junit:4.12'}

settings.gradle

include ':app', ':sample', ':library'

解决方法:

Error:(16, 0) Gradle DSL method not found: ‘compileSdkVersion()’

您不能在顶级文件中使用此语法:

ext {    compileSdkVersion 25    buildToolsversion "25.0.2"    minSdkVersion 16    targetSdkVersion 25}

相反,你可以使用这种语法(注意=)

ext {    // The following are only a few examples of the types of propertIEs you can define.    compileSdkVersion = 25    buildToolsversion = "26.0.1"    ...}

总结

以上是内存溢出为你收集整理的android – 找不到Gradle DSL方法:将模块导入项目后’compileSdkVersion()’全部内容,希望文章能够帮你解决android – 找不到Gradle DSL方法:将模块导入项目后’compileSdkVersion()’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1120232.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存