简体   繁体   English

如何在使用“classpath”com.android.tools.build:gradle:2.3.3'时修复build.gradle错误

[英]How to fix build.gradle error while using “ classpath 'com.android.tools.build:gradle:2.3.3' ”

This is my android gradle file. 这是我的android gradle文件。 I am getting error android gradle plugin that does not contain the method (eg 'testcompile' was added in 1.1.0.). 我收到错误的android gradle插件,它不包含该方法(例如,在1.1.0中添加了'testcompile')。 How can I fix this problem. 我该如何解决这个问题。

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.xxx.xxxx"
        minSdkVersion 15
        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'
        }
    }
}
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    classpath 'com.android.tools.build:gradle:2.3.3'
    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 group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
    testCompile group: 'junit', name: 'junit', version: '4.+'
    compile 'com.android.support.test:runner:0.5'
}

Error 错误

在此输入图像描述

After the correction now the build. 修正后现在构建。 gradle looks like this and now i ge the the error as " Error:(20, 0) Gradle DSL method not found: 'classpath()' Possible causes: gradle看起来像这样,现在我把错误称为“错误:(20,0)未找到Gradle DSL方法:'classpath()'可能的原因:

  • The project 'WeatherApp' may be using a version of the Android Gradle plug-in that does not contain the method (eg 'testCompile' was added in 1.1.0). 项目'WeatherApp'可能正在使用不包含该方法的Android Gradle插件版本(例如,在1.1.0中添加了'testCompile')。 Upgrade plugin to version 2.3.3 and sync project 将插件升级到版本2.3.3并同步项目
  • The project 'WeatherApp' may be using a version of Gradle that does not contain the method. 项目“WeatherApp”可能正在使用不包含该方法的Gradle版本。 Open Gradle wrapper file 打开Gradle包装文件
  • The build file may be missing a Gradle plugin. 构建文件可能缺少Gradle插件。 Apply Gradle plugin 应用Gradle插件
  • "

     apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.xx.xxxxx" minSdkVersion 15 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 { classpath 'com.android.tools.build:gradle:2.3.3' } } } repositories { mavenCentral() jcenter() } dependencies { compile 'com.facebook.android:facebook-android-sdk:[4,5)' compile 'com.google.android.gms:play-services-auth:9.2.1' 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 group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final' testCompile group: 'junit', name: 'junit', version: '4.+' compile 'com.android.support.test:runner:0.5' } 

    In your dependencies block you have to remove this line dependencies块中,您必须删除此行

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

    This line should be used in the buildscript block, something like: 这行应该在buildscript块中使用,例如:

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
        }
    }
    

    Remove classpath 'com.android.tools.build:gradle:2.3.3' from there and add it to your top-level build.gradle file. 从那里删除classpath 'com.android.tools.build:gradle:2.3.3' build.gradle classpath 'com.android.tools.build:gradle:2.3.3'并将其添加到顶级build.gradle文件中。

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
        }
    }
    

    暂无
    暂无

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

    相关问题 找不到com.android.tools.build:gradle:2.3.3 - Could not find com.android.tools.build:gradle:2.3.3 找不到 com.android.tools.build.gradle:7.3.3。 在 build.gradle 文件中发现错误 - Could not find com.android.tools.build:gradle:7.3.3. error found in build.gradle file 错误:找不到 com.android.tools.build:gradle:3.5.2 - ERROR: Could not find com.android.tools.build:gradle:3.5.2 错误:找不到 com.android.tools.build:gradle:3.5.3 - Error : Could not find com.android.tools.build:gradle:3.5.3 错误:找不到com.android.tools.build:gradle:3.4.1 - ERROR: Could not find com.android.tools.build:gradle:3.4.1 错误:找不到com.android.tools.build:gradle:2.2.3 - Error:Could not find com.android.tools.build:gradle:2.2.3 从com.android.tools.build:gradle:3.0.1升级到com.android.tools.build:gradle:3.2.0 - Upgrading from com.android.tools.build:gradle:3.0.1 to com.android.tools.build:gradle:3.2.0 无法解析配置 ':classpath' 的所有工件。 无法解析 com.android.tools.build:gradle:3.5.3。 显示错误 - Could not resolve all artifacts for configuration ':classpath'. Could not resolve com.android.tools.build:gradle:3.5.3. shows error 找不到参数的方法classpath()[com.android.tools.build:gradle:3.4.2] - Could not find method classpath() for arguments [com.android.tools.build:gradle:3.4.2] 无法解析配置“:classpath”的所有工件。 > 无法解析 com.android.tools.build:gradle:4.1.0 - Could not resolve all artifacts for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:4.1.0
     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM