无法为类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象获取未知属性'classpath'

时间:2017-08-13 07:17:20

标签: android ionic-framework ionic2

我正在为Android设备构建Ionic应用程序。我的gradle版本是3.3。我是这个Android大楼的第一个计时器。我收到了以下错误:

Build file 'E:\FarmApp\smartFarm\platforms\android\build.gradle' line: 33

    * What went wrong:
    A problem occurred evaluating root project 'android'.
    > Could not get unknown property 'classpath' for object of type
    org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

我的build.gradle文件部分如下

 buildscript {
repositories {
    mavenCentral()
    jcenter()
}

// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3',
    classpath 'com.google.gms:google-services:3.1.0'
}
}

 // Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
    mavenCentral();
    jcenter()
  }
 }

task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}

2 个答案:

答案 0 :(得分:16)

删除classpath末尾的逗号。这对我有用。

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.1.0'
}

答案 1 :(得分:0)

尝试从android删除ionic平台,然后使用以下命令将其重新添加回来

   $ ionic platform remove android
   $ ionic platform add android