0

I have followed everything according to document provided by google, but am facing some issues, I have added google-services.json in root directory i.e in app.

Error:

Execution failed for task ':app:processDebugGoogleServices'. No matching client found for package name 'com.google.samples.quickstart.analytics'

am getting this error. do help am working on android studio.

Euporie
  • 1,896
  • 1
  • 21
  • 23
aadhagupta
  • 47
  • 1
  • 8

3 Answers3

0

Try resolving the issue by adding the following line in the dependencies of the project-level build.gradle:

classpath 'com.google.gms:google-services:1.5.0'

Archit Goel
  • 694
  • 5
  • 19
  • I added it, is R.xml.global_tracker is auto generated. Am confused about this, please guide me. how to get this global_tracker file. – aadhagupta Feb 16 '16 at 05:29
  • @aadhagupta you have to add global_track.xml to your res/xml/ folder youself. Please see this link for global_track.xml http://stackoverflow.com/questions/33637999/google-analytics-v4-string-xml-configuration-name-not-recognized-ga-trackingi – cwhsu Apr 19 '16 at 00:34
0

Now Use like this in build.gradle: com.google.android.gms:play-services-analytics:8.4.0

And follow this instructions: Add Analytics to Your Android App

You can also generate configuration file from there Follow the title: Add the configuration file to your project

Hope it will helpful for you.

EDIT:

Also please check if your build.gradle contains this line then remove it:

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

Darshak
  • 2,298
  • 4
  • 23
  • 45
  • I have done as it is but still am getting this error. i followed the https://github.com/googlesamples/google-services/blob/master/android/analytics/app/src/main/java/com/google/samples/quickstart/analytics/MainActivity.java this code, I added the global_tracker.xml also, added google-services.json also. – aadhagupta Feb 16 '16 at 04:54
0

Seriously, Google should really make GA easier for all of us!!

Here's how I manage to get it work on buildToolsVersion '23.0.3' with com.google.android.gms:play-services:8.4.0

app build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId 'com.xxx.xxx'
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res/layouts/account',
                            'src/main/res/layouts/drawer',
                            'src/main/res/layouts/ntd',
                            'src/main/res/layouts/main',
                            'src/main/res/layouts',
                            'src/main/res'
                    ]
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.google.android.gms:play-services:8.4.0'        
}
  • I actually remove this line compile 'com.google.android.gms:play-services-analytics:8.4.0' and it still works.

top-level 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.0.0'
        classpath 'com.google.gms:google-services:2.0.0-alpha6'

        // 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
}

GAV4 is really a pain in the axx, so I would also like to remind you somethings.

google-services.json

Official GAV4 Document tells you to generate google-services.json and put it under your project/app/ folder. However, it never says anything about this message.

AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See google short url for instructions.

And I end up find the solution here analyticsservice-not-registered-in-the-app-manifest-error

json with flavor

If you are building a complex project, you might also want to use flavor for different json files. See the flavor config here google-services-json-for-different-productflavors?lq=1

xml app tracker

Yet, you would still have a hard time using xml to configure the tracker, so I also advice you to see this thread google-analytics-v4-string-xml-configuration-name-not-recognized-ga-trackingi

google_app_id

Finally, you would still see 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.

which you could find some discussion here googleservice-failed-to-initialize

In strings.xml, I do add R.string.google_app_id which is your project id in google api console, but I think it would still work even without it. I just want to get rid of that message from the log.

Wish you all good luck!

Community
  • 1
  • 1
cwhsu
  • 1,493
  • 24
  • 31