Ошибка синхронизации Gradle .. отсутствует google

Я не такой бог в студии Android, но я пытаюсь заставить его работать. Но когда я застрял, мне теперь нечего делать. Так что теперь я надеюсь, что кто-нибудь может мне помочь.

У меня 5 ошибок.

Ошибка: не удалось устранить: com.google.android.gms: play-services-auth-api-phone: 11.8.0

Ошибка: не удалось устранить: com.google.android.gms: play-services-basement: 11.8.0

Ошибка: не удалось устранить: com.google.android.gms: play-services-auth-base: 11.8.0

Ошибка: не удалось устранить: com.google.android.gms: play-services-tasks: 11.8.0

Ошибка: не удалось устранить: com.google.android.gms: play-services-base: 11.8.0

Я не могу установить репозиторий и синхронизировать проект.

это мой градл:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        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
}

и это:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25"
    defaultConfig {
        applicationId "xxxxxxx"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 9
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        maven {
            url uri('mint-plugin-repo-5.1.0')
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
}

repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //For error logcat
    compile 'com.google.android.gms:play-services:11.0.4'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    compile 'com.android.support:design:25.3.1'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.android.gms:play-services-gcm:11.0.4'
    compile 'com.android.support:support-annotations:25.3.1'
    compile 'com.facebook.android:facebook-android-sdk:4.12.1'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.intuit.sdp:sdp-android:1.0.4'
    compile 'com.google.maps.android:android-maps-utils:0.4.+'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile 'com.splunk:mint-android-sdk:5.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.daasuu:CountAnimationTextView:0.1.1'
    compile 'com.facebook.android:account-kit-sdk:4.+'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
0
0
580
2

Ответы 2

Добавьте google() и добавьте это перед jcenter(), как это в вашем градиенте, и еще одна важная вещь, которую вы должны использовать implementation вместо compile:

buildscript {
    repositories {
        google()    // add this
        jcenter()
        mavenCentral()
        maven {
             url 'https://maven.google.com/'
             name 'Google'
           }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        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 {
        google()   // add this
        jcenter()
        mavenCentral()
            maven {
              url 'https://maven.google.com/'
              name 'Google'
          }
    }
}

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

и это:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25"
    defaultConfig {
        applicationId "xxxxxxx"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 9
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        maven {
            url uri('mint-plugin-repo-5.1.0')
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
}

repositories {
    mavenCentral()
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //For error logcat
    implementation 'com.google.android.gms:play-services:11.0.4'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.android.support:multidex:1.0.1'
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
    implementation 'com.mikhaellopez:circularimageview:3.0.2'
    implementation 'com.android.support:design:25.3.1'
    implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
    implementation 'com.android.support:support-v4:25.3.1'
    implementation 'com.google.android.gms:play-services-auth:11.0.4'
    implementation 'com.google.android.gms:play-services-gcm:11.0.4'
    implementation 'com.android.support:support-annotations:25.3.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.12.1'
    implementation 'com.google.firebase:firebase-messaging:9.0.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.intuit.sdp:sdp-android:1.0.4'
    implementation 'com.google.maps.android:android-maps-utils:0.4.+'
    implementation 'com.koushikdutta.ion:ion:2.+'
    implementation 'com.splunk:mint-android-sdk:5.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.daasuu:CountAnimationTextView:0.1.1'
    implementation 'com.facebook.android:account-kit-sdk:4.+'
    testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

попробуйте это, и все, что я получу, это ошибка: метод Gradle DSL не найден: 'google ()'

Niklas 26.11.2018 14:45

Что вы хотите сказать?

Abhinav Gupta 26.11.2018 14:47

Не работает .....

Niklas 26.11.2018 14:48

репозитории {mavenCentral ()} удалите это, потому что он полностью принимает maven

Abhinav Gupta 26.11.2018 14:54

Вам необходимо добавить google() в файл build.gradle на уровне проекта. Добавьте его перед jcenter(). Также обратите внимание, что compile устарел, и вместо него следует использовать implementation.

РЕДАКТИРОВАТЬ

Если вышеуказанное не работает, вам может потребоваться отключить параметр автономной работы gradle в «Файл >> Настройки >> Сборка, выполнение, развертывание >> Gradle >> Автономная работа».

нет, это не работает .....

Niklas 26.11.2018 15:07

@Niklas См. Мою правку

Ezekiel Sebastine 26.11.2018 15:17

теперь я получаю это: Ошибка: не удалось найти play-services-auth.jar (com.google.android.gms: play-services-auth: 11.8.0)

Niklas 26.11.2018 15:38

Обновите версию Gradle до 3.2.1, с play-services до 4.0.1, затем перейдите к своим файлам gradle-wrapper.properties и обновите значение до gradle-4.6-all.zip

Ezekiel Sebastine 26.11.2018 15:51

все, что я пробую, я получаю ошибку. пытаюсь обновить, перейти на новую версию. И теперь это приложение работает.

Niklas 26.11.2018 23:23

это единственная ошибка, которую я получаю сейчас ... Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug] и registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) и последний Parsing json file: /home/niklas/Desktop/app/google-services.json

Niklas 28.11.2018 15:52

Другие вопросы по теме