ไม่พบ com.google.gms:google-services:3.1.1

ฉันได้รับข้อยกเว้น:

Could not find com.google.gms:google-services:3.1.1. 

เมื่อฉันเริ่มโปรเจ็กต์ Android

build.gradle ของฉัน (โครงการ: android)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

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

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

และ build.gradle (โมดูล: แอพ)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "de.derdoenerdon.ressourcencockpit"
        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 {
    implementation 'com.android.support:support-v4:25.4.0'
    implementation 'com.android.support:recyclerview-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    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.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.4.0'


    compile 'com.github.OPCFoundation:UA-Java:1.03.342.0'


    testCompile 'junit:junit:4.12'
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.7'

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.1.1'
    }
}
apply plugin: 'com.google.gms.google-services'

เกี่ยวกับความช่วยเหลือใด ๆ ฉันจะขอบคุณมาก ฉันใหม่ใน Android มันเกิดขึ้นเนื่องจากฉันพยายามใช้ firebase ในแอปพลิเคชันของฉัน และมันเพิ่มการพึ่งพาบางส่วนในแอปพลิเคชันของฉันโดยอัตโนมัติ ขอบคุณมาก

แก้ไข: นี่คือลักษณะที่ gradle.build (โมดูล: แอพ) ของฉันดูตอนนี้:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "de.derdoenerdon.ressourcencockpit"
        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 {
    implementation 'com.android.support:support-v4:25.4.0'
    implementation 'com.android.support:recyclerview-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.github.OPCFoundation:UA-Java:1.03.342.0'


    testImplementation 'junit:junit:4.12'
    testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.7'

}


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

และนี่คือคำเตือนซึ่งฉันได้รับเป็นผลลัพธ์:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html 

ไม่มีใครรู้วิธีการลบคำเตือนนี้? ขอบคุณ


person New GenerationFashion    schedule 15.04.2018    source แหล่งที่มา


คำตอบ (1)


เพิ่มคลาสพาธ

 'com.google.gms:google-services:3.1.1'

ในโปรเจ็กต์ gradle ในการอ้างอิงที่ไม่ได้อยู่ใน module.app gradle ดังนี้:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath 'com.google.gms:google-services:3.1.1'

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
person Hesham Morsy    schedule 15.04.2018
comment
@NewGenerationFashion ตรวจสอบหลังจากแก้ไขคำตอบแล้วบอกฉันว่าทุกอย่างโอเค :) - person Hesham Morsy; 15.04.2018
comment
การอ้างอิง { classpath 'com.android.tools.build:gradle:3.1.1' classpath 'com.google.gms:google-services:3.1.1' // หมายเหตุ: อย่าวางการพึ่งพาแอปพลิเคชันของคุณที่นี่ พวกเขาอยู่ใน // ในแต่ละโมดูล build.gradle ไฟล์ } นี่คือลักษณะการพึ่งพาในโปรเจ็กต์ gradle และฉันได้รับสิ่งนี้: ไม่พบ com.google.gms:google-services:3.1.1 จำเป็นโดย: project :app ค้นหาในไฟล์ build.gradle - Salam - person New GenerationFashion; 15.04.2018
comment
buildscript { dependencies { classpath 'com.google.gms:google-services:3.1.1' } } ขออภัย ฉันลบสิ่งนี้ด้านบนใน gradle.build ของ Module:app และตอนนี้ฉันได้รับสิ่งนี้: เวอร์ชัน Android SDK Build Tools ที่ระบุ (26.0.2) จะถูกละเว้น เนื่องจากต่ำกว่าเวอร์ชันขั้นต่ำที่รองรับ (27.0.3) สำหรับ Android Gradle Plugin 3.1.1 เราจะใช้เครื่องมือ Android SDK Build Tools 27.0.3 หากต้องการระงับคำเตือนนี้ ให้ลบ buildToolsVersion '26.0.2' ออกจากไฟล์ build.gradle เนื่องจากเป็นปลั๊กอิน Android Gradle แต่ละเวอร์ชัน - person New GenerationFashion; 15.04.2018
comment
classpath 'com.google.gms:google-services:3.1.0' ไม่ใช่ 3.1.1 - person Hesham Morsy; 15.04.2018
comment
เวอร์ชัน Android SDK Build Tools ที่ระบุ (26.0.2) จะถูกละเว้น เนื่องจากต่ำกว่าเวอร์ชันขั้นต่ำที่รองรับ (27.0.3) สำหรับ Android Gradle Plugin 3.1.1 เราจะใช้เครื่องมือ Android SDK Build Tools 27.0.3 หากต้องการระงับคำเตือนนี้ ให้ลบ buildToolsVersion '26.0.2' ออกจากไฟล์ build.gradle เนื่องจากตอนนี้ปลั๊กอิน Android Gradle แต่ละเวอร์ชันมีเครื่องมือสร้างเวอร์ชันเริ่มต้นแล้ว อัปเดตเวอร์ชันเครื่องมือสร้างและซิงค์โปรเจ็กต์ เปิดไฟล์ ฉันได้รับสิ่งนี้ด้านบน .. ฉันยินดีเป็นอย่างยิ่งหากคุณสามารถช่วยฉันได้ ขอบคุณ - person New GenerationFashion; 15.04.2018
comment
การอ้างอิง { classpath 'com.android.tools.build:gradle:3.1.1' classpath 'com.google.gms:google-services:3.1.0' // หมายเหตุ: อย่าวางการพึ่งพาแอปพลิเคชันของคุณที่นี่ มันเป็นของ // ในแต่ละโมดูล build.gradle ไฟล์ } ฉันใส่สิ่งนี้ไว้ด้านบนและยังคงได้รับคำเตือนนี้: เวอร์ชัน Android SDK Build Tools ที่ระบุ (26.0.2) จะถูกละเว้น เนื่องจากต่ำกว่าเวอร์ชันขั้นต่ำที่รองรับ (27.0.3) ) สำหรับปลั๊กอิน Android Gradle 3.1.1 เราจะใช้เครื่องมือ Android SDK Build Tools 27.0.3 หากต้องการระงับคำเตือนนี้ ให้ลบ buildToolsVersion '26.0.2' ออกจากของคุณ - person New GenerationFashion; 15.04.2018
comment
จะเกิดอะไรขึ้นเมื่อคุณลบ buildToolsVersion '26.0.2' - person Hesham Morsy; 15.04.2018
comment
ไม่มีอะไร .. ฉันอัปเดตแล้วตอนนี้ gradle.build ฉันแก้ไขโพสต์ของฉัน จะขอบคุณมากหากคุณสามารถช่วยได้ ฉันเพิ่งได้รับคำเตือน แต่ทุกอย่างดูโอเค ถ้าลบคำเตือนได้จะดีมาก - person New GenerationFashion; 15.04.2018
comment
@NewGenerationFashion โปรดลองแทนที่แต่ละคำใน (โมดูล: แอพ) gradle ตามที่ปรากฏในคำเตือน (ตัวอย่าง: androidTestCompile แทนที่ด้วย androidTestImplementation) ฯลฯ ลองสิ่งนี้แล้วบอกผลลัพธ์ให้ฉันหน่อย :) - person Hesham Morsy; 15.04.2018
comment
ขอบคุณ ฉันทำได้แล้ว ฉันสับสนว่าเหตุใดฉันจึงสามารถลบบางสิ่งเป็นการนำไปใช้หรือเป็น api ได้ เพราะฉันคิดว่าความหมายจะแตกต่างออกไป แต่ตอนนี้ฉันได้รับคำเตือนเพียงครั้งเดียว แต่ฉันไม่รู้ว่าจะลบมันได้อย่างไร ฉันแก้ไขอีกครั้ง คงจะดีใจมากถ้าคุณสามารถดู ;) ขอบคุณ :) - person New GenerationFashion; 15.04.2018
comment
คุณจะแทนที่ (คอมไพล์) ด้วย (การนำไปใช้งาน) เนื่องจากคอมไพล์คีย์เวิร์ดจะเลิกใช้งานหลังปี 2018 ลองสิ่งนี้แล้วบอกฉันว่าจะเกิดอะไรขึ้น :) - person Hesham Morsy; 15.04.2018
comment
ฉันไม่มีการคอมไพล์ใน build.gradle (โมดูล: แอป) อีกต่อไป .. นี่เป็นคำเดียวที่คอมไพล์ SdkVersion 25 ที่มีการคอมไพล์และถ้าฉันแทนที่การคอมไพล์นี้เป็น ImplementSdkVersion 25 ฉันจะได้รับข้อผิดพลาด - person New GenerationFashion; 15.04.2018
comment
ไม่ อย่าเปลี่ยน compilSdkVersion หากคุณแน่ใจว่าไม่มีคำคอมไพล์ ให้ลองล้างโปรเจ็กต์แล้วสร้างโปรเจ็กต์ .. แล้วบอกฉันว่าคุณเห็นอะไรอีกครั้ง - person Hesham Morsy; 15.04.2018
comment
ฉันทำมัน. ตอนนี้ฉันได้รับสิ่งนี้เท่านั้น: คำเตือน: การกำหนดค่า 'คอมไพล์' ล้าสมัยและถูกแทนที่ด้วย 'การใช้งาน' และ 'api' และฉันไม่มีการคอมไพล์ใน gradle นี้ แต่สร้างโปรเจ็กต์ได้สำเร็จ - person New GenerationFashion; 15.04.2018
comment
@NewGenerationFashion โปรดลองอัปเดต classpath 'com.google.gms:google-services:3.1.1' เป็น 3.2.0 - person Hesham Morsy; 15.04.2018
comment
ขอบคุณ ตอนนี้ทุกอย่างดูเหมือนจะทำงานได้ดี! ฉันยินดีเป็นอย่างยิ่ง หากคุณสามารถช่วยฉันเรื่อง firebase ได้ นั่นเป็นอีกคำถามหนึ่งสำหรับฉัน ขอขอบคุณและสลาม - person New GenerationFashion; 15.04.2018
comment
ดีใจที่ได้ยินอย่างนั้น :) ฉันไม่ได้ใช้ firebase เมื่อปีที่แล้ว เลยไม่รู้ว่าจะจำได้ไหม แต่ฉันจะเห็นคำถามของคุณ .. ยังไงก็ตาม ขอให้โชคดีกับโครงการของคุณ ^_^ - person Hesham Morsy; 15.04.2018
comment
ขอบคุณเช่นกัน คุณช่วยฉันได้มาก - person New GenerationFashion; 15.04.2018