将Firebase添加到项目后无法同步Gradle

时间:2018-06-30 07:51:00

标签: android maven firebase gradle google-play-services

我正在使用android studio 3.0.1。在将Firebase添加到我的项目之一之后。同步项目gardle时出现了著名的错误。

Failed to resolve: com.google.android.gms:play-services-maps:16.1.1 Failed to resolve: com.google.firebase:firebase-core:16.1.1 Failed to resolve: com.google.android.gms:play-services-location:16.1.1

和其他与firebase相关的库。经过一番搜索,我意识到我们应该安装google play服务sdk并将google maven存储库添加到我的项目gradle存储库中。但是我已经做到了。

这是我的项目gradle代码

    buildscript {

        repositories {
           google()
           jcenter()
           maven {
              url 'https://maven.fabric.io/public'
          }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.0.1'
       }
    }

    allprojects {
        repositories {
           google()
           jcenter()
      }
    }

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

这是我的应用程序模块gradle

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'


android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.app4charkh.user"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        manifestPlaceholders = [onesignal_app_id: "APP-ID", onesignal_google_project_number: "REMOTE"]

        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "GOOGLE_API")
//        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

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

}

dependencies {


    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.matthew-tamlin:sliding-intro-screen:3.2.0'
//    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:27.1.1'
    compile 'com.google.android.gms:play-services-maps:15.0.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.okhttp3:okhttp:3.5.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'

    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    compile 'io.reactivex:rxandroid:1.2.0'
    compile 'io.reactivex:rxjava:1.1.4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'

    compile 'com.onesignal:OneSignal:[3.8.4, 3.99.99]'

    compile 'com.github.adityagohad:HorizontalPicker:1.0.1'
    compile 'com.ramotion.circlemenu:circle-menu:0.3.0'
    compile 'com.github.lukedeighton:wheelview:0.4.1'

//    compile 'com.journeyapps:zxing-android-embedded:3.5.0'

    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.easing:library:1.0.1@aar'
    compile 'com.daimajia.androidanimations:library:1.1.3@aar'
    compile 'com.github.florent37:arclayout:1.0.3'
    compile 'com.flaviofaria:kenburnsview:1.0.7'

    compile 'org.parceler:parceler-api:1.1.9'
    annotationProcessor 'org.parceler:parceler:1.1.9'

    implementation 'com.github.bumptech.glide:glide:4.5.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'

    compile 'org.greenrobot:eventbus:3.1.1'
    compile 'me.zhanghai.android.materialratingbar:library:1.2.0'

    compile 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'

    compile 'com.github.markomilos:paginate:0.5.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

0 个答案:

没有答案