0

我是Android Studio 2.3.3上的Android應用開發新手。我遵循Firebase數據庫指南連接到數據庫。但是在執行同步時失敗(請參閱下面的錯誤)。很多人問我同樣的問題,但這些解決方案似乎對自己的gradle文件來說太具體,所以我可以用它來修復我的應用程序。在添加「適用插件:'com.google.gms.google-services'」for Firebase數據庫時無法同步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.3.3' 
     classpath 'com.google.gms:google-services:3.1.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 
} 

的build.gradle:任何幫助將:-)

Error:Execution failed for task ':app:processDebugGoogleServices'. 
> No matching client found for package name 'com.example.lenovo.hereandthere' 

的build.gradle(HereAndThere項目)理解(模塊:APP)

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.1" 
    defaultConfig { 
     applicationId "com.example.lenovo.hereandthere" 
     minSdkVersion 19 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    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:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 
} 

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

注: enter image description here

+0

加入谷歌服務的JSON文件 – Killer

+0

Shubham喜,哪些文件,哪裏以及如何? – ronan101010101

+0

https://developers.google.com/android/guides/google-services-plugin#adding_the_json_file您需要一個谷歌服務json文件才能使用谷歌服務插件 – Killer

回答

0

沒有找到匹配的客戶端軟件包名稱「com.example.lenovo.hereandthere」

可發生的原因如下,因爲之一所述的問題:

  1. 沒有谷歌服務上傳.json文件存在
  2. 或谷歌服務上傳.json文件存在但放置在錯誤的位置。 check out this
  3. 或包的名稱是從谷歌的服務以.json提到的不同(人們通常不這樣做,但不幸的是這 是你的情況。)
+0

是的,謝謝!我用正確的軟件包名稱重新創建了一個新項目。我現在可以讀取和寫入數據庫。這真是太痛苦了。 – ronan101010101

相關問題