无法为参数找到方法has()

时间:2017-03-25 16:02:39

标签: android android-gradle android-volley

构建Android项目时出现以下错误。

  

错误:找不到类型为org.gradle.api.Project的项目':volley'上的参数[release]的方法has()。

以下是我的build.gradle文件

项目级别:

// 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:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级别:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

//apply plugin: 'realm-android'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.haha.sampleappid"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile project(':volley') //TODO:add as gradle dependency which will be while enabling proguard
    compile('com.digits.sdk.android:digits:1.11.1@aar') {
        transitive = true;
    }
    compile "com.android.support:recyclerview-v7:23.0.1"
    compile 'com.google.firebase:firebase-ads:9.4.0'
}

apply plugin: 'com.google.gms.google-services'

凌空/的build.gradle

// NOTE: The only changes that belong in this file are the definitions
// of tool versions (gradle plugin, compile SDK, build tools), so that
// Volley can be built via gradle as a standalone project.
//
// Any other changes to the build config belong in rules.gradle, which
// is used by projects that depend on Volley but define their own
// tools versions across all dependencies to ensure a consistent build.
//
// Most users should just add this line to settings.gradle:
//     include(":volley")
//
// If you have a more complicated Gradle setup you can choose to use
// this instead:
//     include(":volley")
//     project(':volley').buildFileName = 'rules.gradle'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
}

apply plugin: 'com.android.library'

repositories {
    jcenter()
}

android {
    compileSdkVersion 22
    buildToolsVersion = '22.0.1'
}

apply from: 'rules.gradle'
apply from: 'bintray.gradle'

之前有没有人遇到过类似的问题?

建议将不胜感激。

1 个答案:

答案 0 :(得分:2)

打开Volley的bintray.gradle文件,找到以下内容:

publish = project.has("release")

并将该行更改为

publish = project.hasProperty("release")

这解决了大多数情况下的问题。