Java Gradle生成错误:提供的字符串模块表示法

Java Gradle生成错误:提供的字符串模块表示法,java,android,firebase,android-studio,gradle,Java,Android,Firebase,Android Studio,Gradle,我在做一个项目 我试图使用我自己的Firebase和Google API密钥。我已经添加了所有依赖项和Firebase SDK,但是当我尝试同步项目时。我收到了以下错误 ERROR: Supplied String module notation 'deps.android.support.design' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:jav

我在做一个项目

我试图使用我自己的Firebase和Google API密钥。我已经添加了所有依赖项和Firebase SDK,但是当我尝试同步项目时。我收到了以下错误

ERROR: Supplied String module notation 'deps.android.support.design' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
Open File
我的应用程序build.gradle是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion buildConfig.compileSdk

    defaultConfig {
        applicationId "com.udacity.nanodegree.blooddonation"
        minSdkVersion buildConfig.minSdk
        targetSdkVersion buildConfig.targetSdk
        versionCode buildConfig.version.code
        versionName buildConfig.version.name
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {

        debug {
            debuggable true
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        buildTypes.each {
            it.resValue('string', "google_maps_key", propOrThrow('GOOGLE_MAPS_API_KEY'))
        }
    }

    lintOptions {
        textReport true
        textOutput 'stdout'
        lintConfig rootProject.file('lint.xml')

        checkDependencies true
        checkTestSources true
        explainIssues false
    }


    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // Support lib
    implementation "deps.android.support.appcompatV7"

    // Support Design
    implementation "deps.android.support.design"

    // Constraint layout
    implementation "deps.android.support.design"

    implementation 'com.google.firebase:firebase-analytics:17.2.0'

    // Firebase Auth
    implementation "deps.google.firebase.auth"

    // Realtime database
    implementation "deps.google.firebase.database"

    //Country code picker
    // https://android-arsenal.com/details/1/5753 // TODO: move to project level gradle
    implementation 'com.github.joielechong:countrycodepicker:2.1.5'

    // Leak canary
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    debugImplementation "deps.square.leackcanary.debug"
    releaseImplementation "deps.square.leackcanary.release"

    // Timber - Logging library
    implementation "deps.square.leackcanary.release"

    // Fused location
    implementation "deps.square.leackcanary.release"

    // Geo-fire
    implementation "deps.google.firebase.geo_fire"

    // Map
    implementation "deps.google.play_services.maps"

    // PinView // TODO: move to project level gradle
    implementation 'com.github.GoodieBag:Pinview:v1.3'

    implementation "deps.google.play_services.maps"

    implementation "deps.google.play_services.maps"





    testImplementation "deps.junit"

    androidTestImplementation "deps.android.support.test.runner"
    androidTestImplementation "deps.android.support.test.espressoCore"

}


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

    ext.versions = [
            'supportLibrary'  : '27.1.1',
            'constraintLayout': '1.1.0',
            'firebase'        : '15.0.2',
            'testRunner'      : '1.0.1',
            'espressoCore'    : '3.0.1',
            'leak_canary'     :  '1.5.4',
            'timber'          : '4.7.0',
            'play_services'   : '15.0.0',
            'geo_fire'        : '2.3.1',
            'gson'            : '2.8.4',
            'fcm'             : '15.0.2',
            'firebase_auth'   : '15.1.0',
            'firebase_database':'15.0.0'

    ]


    ext.buildConfig = [
            'compileSdk': 27,
            'targetSdk' : 27,
            'minSdk'    : 16,
            'isSnapshot': false,

            'version'   : [
                    'major'     : 1,
                    'minor'     : 0,
                    'patch'     : 0,
                    'classifier': null, // dev, beta, alpha etc.
            ]
    ]

    String versionName = "${buildConfig.version.major}.${buildConfig.version.minor}.${buildConfig.version.patch}"

    if (buildConfig.version.classifier == null) {
        if (buildConfig.isSnapshot) {
            buildConfig.version.classifier = 'SNAPSHOT'
        }
    }

    if (buildConfig.version.classifier != null) {
        versionName += "-" + buildConfig.version.classifier
    }

    ext.buildConfig.version['name'] = versionName
    ext.buildConfig.version['code'] = buildConfig.version.major * 100000 + buildConfig.version.minor * 10000 + buildConfig.version.patch * 100


    ext.deps = [
            'android': [
                    'support': [
                            'appcompatV7'     : "com.android.support:appcompat-v7:${versions.supportLibrary}",
                            'annotations'     : "com.android.support:support-annotations:${versions.supportLibrary}",
                            'constraintLayout': "com.android.support.constraint:constraint-layout:${versions.constraintLayout}",
                            'design'          : "com.android.support:design:${versions.supportLibrary}",
                            'test'            : [
                                    'runner'      : "com.android.support.test:runner:${versions.testRunner}",
                                    'espressoCore': "com.android.support.test.espresso:espresso-core:${versions.espressoCore}"
                            ]
                    ],
            ],

            'google' : [
                    'firebase': [
                            'auth': "com.google.firebase:firebase-auth:${versions.firebase_auth}",
                            'database':"com.google.firebase:firebase-database:${versions.firebase_database}",
                            'geo_fire':"com.firebase:geofire-android:${versions.geo_fire}",
                            'cloud_messaging':"com.google.firebase:firebase-messaging:${versions.fcm}"
                    ],
                    'play_services':[
                        'location':"com.google.android.gms:play-services-location:${versions.play_services}",
                        'maps':"com.google.android.gms:play-services-maps:${versions.play_services}"
                    ],
                    'gson':[
                            'gson': "com.google.code.gson:gson:${versions.gson}"
                    ]
            ],

            'square':[
                'leackcanary':[
                    'debug':"com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}",
                    'release':"com.squareup.leakcanary:leakcanary-android-no-op:${versions.leak_canary}"
                ]
            ],

            'other':[
                'timber':"com.jakewharton.timber:timber:${versions.timber}"
            ],

            'junit'  : 'junit:junit:4.12'
    ]

    repositories {
        google()
        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'com.google.gms:google-services:4.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }

    // Force all of the primary support libraries to use the same version.
    configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support') {
                details.useVersion versions.supportLibrary
            }
        }
    }
}

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

def propOrThrow(String name) {
    if (hasProperty(name))
        return getProperty(name)
    else
        throw new GradleException("Can't find property `$name`, make sure you have added them to the global 'gradle.properties' file")
}
当我点击错误时,我会带我去
实现“deps.android.support.design”

我的项目build.gradle是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion buildConfig.compileSdk

    defaultConfig {
        applicationId "com.udacity.nanodegree.blooddonation"
        minSdkVersion buildConfig.minSdk
        targetSdkVersion buildConfig.targetSdk
        versionCode buildConfig.version.code
        versionName buildConfig.version.name
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {

        debug {
            debuggable true
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        buildTypes.each {
            it.resValue('string', "google_maps_key", propOrThrow('GOOGLE_MAPS_API_KEY'))
        }
    }

    lintOptions {
        textReport true
        textOutput 'stdout'
        lintConfig rootProject.file('lint.xml')

        checkDependencies true
        checkTestSources true
        explainIssues false
    }


    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // Support lib
    implementation "deps.android.support.appcompatV7"

    // Support Design
    implementation "deps.android.support.design"

    // Constraint layout
    implementation "deps.android.support.design"

    implementation 'com.google.firebase:firebase-analytics:17.2.0'

    // Firebase Auth
    implementation "deps.google.firebase.auth"

    // Realtime database
    implementation "deps.google.firebase.database"

    //Country code picker
    // https://android-arsenal.com/details/1/5753 // TODO: move to project level gradle
    implementation 'com.github.joielechong:countrycodepicker:2.1.5'

    // Leak canary
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    debugImplementation "deps.square.leackcanary.debug"
    releaseImplementation "deps.square.leackcanary.release"

    // Timber - Logging library
    implementation "deps.square.leackcanary.release"

    // Fused location
    implementation "deps.square.leackcanary.release"

    // Geo-fire
    implementation "deps.google.firebase.geo_fire"

    // Map
    implementation "deps.google.play_services.maps"

    // PinView // TODO: move to project level gradle
    implementation 'com.github.GoodieBag:Pinview:v1.3'

    implementation "deps.google.play_services.maps"

    implementation "deps.google.play_services.maps"





    testImplementation "deps.junit"

    androidTestImplementation "deps.android.support.test.runner"
    androidTestImplementation "deps.android.support.test.espressoCore"

}


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

    ext.versions = [
            'supportLibrary'  : '27.1.1',
            'constraintLayout': '1.1.0',
            'firebase'        : '15.0.2',
            'testRunner'      : '1.0.1',
            'espressoCore'    : '3.0.1',
            'leak_canary'     :  '1.5.4',
            'timber'          : '4.7.0',
            'play_services'   : '15.0.0',
            'geo_fire'        : '2.3.1',
            'gson'            : '2.8.4',
            'fcm'             : '15.0.2',
            'firebase_auth'   : '15.1.0',
            'firebase_database':'15.0.0'

    ]


    ext.buildConfig = [
            'compileSdk': 27,
            'targetSdk' : 27,
            'minSdk'    : 16,
            'isSnapshot': false,

            'version'   : [
                    'major'     : 1,
                    'minor'     : 0,
                    'patch'     : 0,
                    'classifier': null, // dev, beta, alpha etc.
            ]
    ]

    String versionName = "${buildConfig.version.major}.${buildConfig.version.minor}.${buildConfig.version.patch}"

    if (buildConfig.version.classifier == null) {
        if (buildConfig.isSnapshot) {
            buildConfig.version.classifier = 'SNAPSHOT'
        }
    }

    if (buildConfig.version.classifier != null) {
        versionName += "-" + buildConfig.version.classifier
    }

    ext.buildConfig.version['name'] = versionName
    ext.buildConfig.version['code'] = buildConfig.version.major * 100000 + buildConfig.version.minor * 10000 + buildConfig.version.patch * 100


    ext.deps = [
            'android': [
                    'support': [
                            'appcompatV7'     : "com.android.support:appcompat-v7:${versions.supportLibrary}",
                            'annotations'     : "com.android.support:support-annotations:${versions.supportLibrary}",
                            'constraintLayout': "com.android.support.constraint:constraint-layout:${versions.constraintLayout}",
                            'design'          : "com.android.support:design:${versions.supportLibrary}",
                            'test'            : [
                                    'runner'      : "com.android.support.test:runner:${versions.testRunner}",
                                    'espressoCore': "com.android.support.test.espresso:espresso-core:${versions.espressoCore}"
                            ]
                    ],
            ],

            'google' : [
                    'firebase': [
                            'auth': "com.google.firebase:firebase-auth:${versions.firebase_auth}",
                            'database':"com.google.firebase:firebase-database:${versions.firebase_database}",
                            'geo_fire':"com.firebase:geofire-android:${versions.geo_fire}",
                            'cloud_messaging':"com.google.firebase:firebase-messaging:${versions.fcm}"
                    ],
                    'play_services':[
                        'location':"com.google.android.gms:play-services-location:${versions.play_services}",
                        'maps':"com.google.android.gms:play-services-maps:${versions.play_services}"
                    ],
                    'gson':[
                            'gson': "com.google.code.gson:gson:${versions.gson}"
                    ]
            ],

            'square':[
                'leackcanary':[
                    'debug':"com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}",
                    'release':"com.squareup.leakcanary:leakcanary-android-no-op:${versions.leak_canary}"
                ]
            ],

            'other':[
                'timber':"com.jakewharton.timber:timber:${versions.timber}"
            ],

            'junit'  : 'junit:junit:4.12'
    ]

    repositories {
        google()
        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath 'com.google.gms:google-services:4.3.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }

    // Force all of the primary support libraries to use the same version.
    configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support') {
                details.useVersion versions.supportLibrary
            }
        }
    }
}

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

def propOrThrow(String name) {
    if (hasProperty(name))
        return getProperty(name)
    else
        throw new GradleException("Can't find property `$name`, make sure you have added them to the global 'gradle.properties' file")
}

请帮帮我。我不明白这个错误

为什么您有重复的依赖项?我从Github下载了这个项目,在这里您可以看到完整的代码并更好地理解。我刚刚添加了Firebase SDK