2016-05-28 60 views
8

我無法在android studio上設置Firebase的更新版本。 我創建的網站火力項目的JSON文件,並將其複製到項目和應對的gradle行之後:Android上的firebase設置

buildscript { 
    // ... 
    dependencies { 
     // ... 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 
apply plugin: 'com.android.application' 
android { 
    // ... 
} 
dependencies { 
    compile 'com.google.firebase:firebase-core:9.0.1' 
} 
// ADD THIS AT THE BOTTOM 
apply plugin: 'com.google.gms.google-services' 

我得到以下錯誤:

failed to resolve: compile 'com.google.firebase:firebase-core:9.0.0'

如何我可以修復它嗎?

+0

嘗試更新谷歌播放服務的SDK。 – DariusL

回答

19

我有同樣的問題。如果您使用Android Studio,則應該在SDK Manager中更新google repository

enter image description here

以下是我build.grade(APP)

apply plugin: 'com.android.application' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 
    useLibrary 'org.apache.http.legacy' 
    defaultConfig { 
     applicationId "package name" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     vectorDrawables.useSupportLibrary = true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

} 

dependencies { 
    compile 'com.google.firebase:firebase-core:9.0.0' 
} 
apply plugin: 'com.google.gms.google-services' 

這是我build.grade

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

排球,okhttp,**和** apache http?爲什麼? –

+0

@ cricket_007對不起,你只是拿着你需要的東西。我告訴那是我的build.gradle。無論如何,我沒有編輯和刪除它們 –

+0

這是確切的解決方案。有效。非常感謝。 –

1

火力地堡是基於工作(項目)在Google Play服務上。所以請確保您有以下sdk工具,並且它們已更新爲與您正在使用的Firebase庫版本同步。

SDK Tools installed for this project

項目一級的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.1.2' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

模塊級別的build.gradle文件

apply plugin: 'com.android.application' 

android { 
    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE-FIREBASE.txt' 
     exclude 'META-INF/NOTICE' 
    } 

    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.devdeeds.firebaseauth" 
     minSdkVersion 17 
     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']) 
    compile 'com.google.firebase:firebase-auth:9.2.0' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.android.support:design:23.3.0' 
} 


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