Theo
Theo

Reputation: 3139

GoogleService failed to initialize because of missing dependency in gradle.

Everything was working perfect in my project but know I get this message.

 GoogleService failed to initialize, status: 10, Missing an expected resource:   
 'R.string.google_app_id' for initializing Google services.  Possible causes 
  are missing google-services.json or com.google.gms.google-services gradle    
  plugin

So I should add the google-service in my gradle file.

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

allprojects {
    repositories {
        jcenter()
  }
}

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

and these are my dependencies.

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'


compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
}

Basically I use the GoogleApiClient object to obtain my current location. I have nothing to do with Maps or GCM.

Any ideas how to fix this? I looked around here, but still there are problems.

Thanks.

Upvotes: 0

Views: 433

Answers (1)

sivaBE35
sivaBE35

Reputation: 1891

  • You need to generate and configure file from Developer.Google google-services.json file from this site.

  • Open the Android Studio Terminal pane: enter image description here

    Alternativiely you can just press ALT + F12

Type this line in Terminal

  • MAC/LINUX:

mv path-to-download/Downloads/google-services.json app/

  • WINDOWS

move path-to-download/Downloads/google-services.json app/

1) Add the dependency to your project-level build.gradle:

 compile 'com.google.gms:google-services:3.0.0'

2) Add the plugin to your app-level build.gradle:

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

note: below dependencies{ ....... } blog

  • Then use Play service dependencies in app level

dependencies { compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.google.android.gms:play-services:9.0.1'
}

Upvotes: 1

Related Questions