Implementing Google Analytics for Android LibGDX Game Screens

I have a problem implementing Google Analytics in the LibGDX game app. I want to track game screens, but Google Analytics only works in the Android directory part of the Gradle project. In the main part, it does not get context for game screen classes, although I added libGoogleAnalyticsServices.jar to the main folder. I searched for solutions over the Internet, but nothing worked, so I can’t initialize Google Analytics in the main part of the project.

This is the code snippet where I am trying to initialize Google Analytics:

GoogleAnalytics GA = GoogleAnalytics.getInstance();

and this gives me this error "The type android.content.Context cannot be resolved. It indirectly refers to the required .class files"

Should I use libGoogleAnalyticsServices.jar of an Android project in Core or use a different jar file for this task?

Below are some links where I found information on this issue.

Google Event Tracker v3 https://developers.google.com/analytics/devguides/collection/android/v3/migration http://badlogicgames.com/forum/viewtopic.php?f=11&t=4298

Any answer to this particular question would be very helpful. Thank you in advance.

+4
source share
2 answers

sdk Google Analytics Android, . . Android .

, , . libgdx

:

public interface Trackable {
   public void trackScreen(String screenName);
}

Google Analytics.

+6

Intellij/ Gradle, Google Play Services :

  • google play services Gradle Android. ( SDK Manager)

    { compile 'com.google.android.gms: play-services: 6.5.87' }

  • Internet Network State .

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
  • min sdk 9 .

    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" />

GA , : http://pygmalion.nitri.de/google-analytics-sdk-v4-with-libgdx-536.html GA.

+2

All Articles