Google Analytics v4 in Android: Could not find class 'com.google.android.gms.analytics.Tracker'

人盡茶涼 提交于 2019-12-11 03:44:52

问题


I am desperately trying to integrate GA v4 in my Android app. And I followed the guide here https://developers.google.com/analytics/devguides/collection/android/v4/

And integrated Google Play Services lib as described, but it gives me

Could not find class 'com.google.android.gms.analytics.Tracker

But I can find classes and its namespaces in the project.

I can't figure out what's happening here.


回答1:


I followed also the instruction on Analytics for Android v4.

But additionally I had to update play services and build tools in the SDK manager. Then I had to add compile 'com.google.android.gms:play-services:8.4.0' in the app build.gradle (above of compile 'com.google.android.gms:play-services-analytics:8.4.0'. The Tracker class was still unknown (red underlined) but despite of that I pressed "Run" (install app) in Android Studio and only then analytics was recognized and could be used.




回答2:


I had the same problem and the reason was my Google Play services package was outdated.

Using Eclipse, I went into Window > Android SDK Manager, checked only Google Play services package (under "Extras" in the bottom), updated it and created a new lib project.

Then I followed the steps in tutorial below to create a new google play services lib project.

https://developer.android.com/google/play-services/setup.html

Hope it helps!

/Paulo



来源:https://stackoverflow.com/questions/25360884/google-analytics-v4-in-android-could-not-find-class-com-google-android-gms-ana

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!