错误:(62,0)未找到Gradle DSL方法:'compile()'

时间:2017-10-05 23:20:43

标签: android android-studio gradle build.gradle

如果我更改包名称,我会收到错误,然后我无法生成签名的APK甚至运行'app' 失败,出现以下错误:

Error:(62, 0) Gradle DSL method not found: 'compile()'
Possible causes:
- The project 'polar-dashboard-master' 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 'polar-dashboard-master' may be using a version of Gradle that does not contain the method.

打开Gradle包装文件      - 构建文件可能缺少Gradle插件。 申请Gradle插件

我的build.gradle(模块:app

apply from: '../dependencies.gradle'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:' + versions.aptPlugin
    }
}

android {
    compileSdkVersion versions.compileSdk
    buildToolsVersion versions.buildTools
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = new File(
                    output.outputFile.parent, "${variant.applicationId}-${variant.versionName}.apk")
        }
    }
    // Note to Aidan sample uses same keystore as Cabinet
    lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId 'com.thegosa.blackstyle.iconpack'
        minSdkVersion versions.minSdk
        targetSdkVersion versions.compileSdk
        versionName "versions.publishVersion"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
//        debug {
//            signingConfig signingConfigs.production
//        }
        release {
//            signingConfig signingConfigs.production
            // Disable Proguard so our drawable-nodpi resources aren't removed
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        // Required by Kustom support to avoid assets being compressed
        aaptOptions {
            noCompress 'zip', 'komp', 'klwp', 'kwgt', 'klck', 'kwch'
        }
    }
    productFlavors {
    }
}

repositories {
    mavenCentral()
    jcenter()
    maven { url "https://dl.bintray.com/drummer-aidan/maven" }
}

dependencies {
    compile project(path: ':licensing')
    compile 'com.afollestad.material-dialogs:core:' + versions.materialDialogs compile 'com.afollestad:drag-select-recyclerview:' + versions.dragSelectRv compile('com.afollestad:bridge:' + versions.bridge)
    {
        exclude group: 'org.json', module: 'json'
    }
    compile 'com.afollestad:sectioned-recyclerview:' + versions.sectionedRv compile 'com.afollestad:assent:' + versions.assent compile 'com.afollestad:icon-request:' + versions.iconRequest compile 'com.afollestad:inquiry:' + versions.inquiry compile 'me.zhanghai.android.materialprogressbar:library:' + versions.mdProgressBar compile 'com.android.support:appcompat-v7:' + versions.supportLib compile 'com.android.support:recyclerview-v7:' + versions.supportLib compile 'com.android.support:support-v13:' + versions.supportLib compile 'com.android.support:design:' + versions.supportLib compile 'com.android.support:cardview-v7:' + versions.supportLib compile 'com.android.support:palette-v7:' + versions.supportLib compile 'com.github.bumptech.glide:glide:' + versions.glide compile "com.github.florent37:glidepalette:$versions.glidePalette@aar" compile 'com.jakewharton:butterknife:' + versions.butterKnife apt 'com.jakewharton:butterknife-compiler:' + versions.butterKnife compile 'com.google.android.apps.muzei:muzei-api:' + versions.muzei compile 'com.makeramen:roundedimageview:' + versions.roundImageView compile 'com.anjlab.android.iab.v3:library:' + versions.iab compile 'com.pluscubed:insets-dispatcher:' + versions.insetDispatcher compile 'org.bitbucket.frankmonza:kustomapi:+'
}

1 个答案:

答案 0 :(得分:3)

我认为您的依赖项部分的每个'compile'指令都应该在一个新行上。

您的依赖项部分应如下所示:

dependencies {
  compile project(path: ':licensing')
  compile 'com.afollestad.material-dialogs:core:' + versions.materialDialogs
  compile 'com.afollestad:drag-select-recyclerview:' + versions.dragSelectRv
  compile ('com.afollestad:bridge:' + versions.bridge) {
        exclude group: 'org.json', module: 'json'
  }
  compile 'com.afollestad:sectioned-recyclerview:' + versions.sectionedRv 
  compile 'com.afollestad:assent:' + versions.assent
  compile 'com.afollestad:icon-request:' + versions.iconRequest
  compile 'com.afollestad:inquiry:' + versions.inquiry
  compile 'me.zhanghai.android.materialprogressbar:library:' + versions.mdProgressBar
  compile 'com.android.support:appcompat-v7:' + versions.supportLib
  compile 'com.android.support:recyclerview-v7:' + versions.supportLib
  compile 'com.android.support:support-v13:' + versions.supportLib
  compile 'com.android.support:design:' + versions.supportLib
  compile 'com.android.support:cardview-v7:' + versions.supportLib
  compile 'com.android.support:palette-v7:' + versions.supportLib
  compile 'com.github.bumptech.glide:glide:' + versions.glide
  compile "com.github.florent37:glidepalette:$versions.glidePalette@aar"
  compile 'com.jakewharton:butterknife:' + versions.butterKnife
  apt 'com.jakewharton:butterknife-compiler:' + versions.butterKnife
  compile 'com.google.android.apps.muzei:muzei-api:' + versions.muzei
  compile 'com.makeramen:roundedimageview:' + versions.roundImageView
  compile 'com.anjlab.android.iab.v3:library:' + versions.iab
  compile 'com.pluscubed:insets-dispatcher:' + versions.insetDispatcher
  compile 'org.bitbucket.frankmonza:kustomapi:+'
}