Google Analytics Tracker not working in Android app

I am a new android developer. I have included Google Analytics in my application. My code is the same as this StackOverflow question.

and I am using the following code:

private static final String TAG = "MainActivity";
Tracker t;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button b = (Button) findViewById(R.id.button1);
    t = ((AnalyticsSampleApp) this.getApplication())
            .getTracker(TrackerName.APP_TRACKER);
    b.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {               
            t.setScreenName(TAG);               
            t.send(new HitBuilders.AppViewBuilder().build());           
        }
    });

}

      

My AndroidManifest.xml

:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampe.a"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:name="com.exampe.a.AnalyticsSampleApp"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <!-- Google Analytics Version v4 needs this value for easy tracking -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.gms.analytics.globalConfigResource"
        android:resource="@xml/global_tracker" />

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
     </activity>
  </application>

</manifest>

      

But when I click on the button, the following error appears:

   09-14 07:48:55.615: E/SoundPool(1273): error loading /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.615: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.615: E/SoundPool(1273): error loading /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: E/SoundPool(1273): error loading /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: E/SoundPool(1273): error loading /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.625: E/SoundPool(1273): error loading /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.635: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
   09-14 07:48:55.635: E/SoundPool(1273): error loading /system/media/audio/ui/KeypressStandard.ogg
  09-14 07:48:55.655: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
  09-14 07:48:55.665: E/SoundPool(1273): error loading /system/media/audio/ui/KeypressSpacebar.ogg
  09-14 07:48:55.665: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
  09-14 07:48:55.665: E/SoundPool(1273): error loading /system/media/audio/ui/KeypressDelete.ogg
  09-14 07:48:55.665: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
  09-14 07:48:55.665: E/SoundPool(1273): error loading /system/media/audio/ui/KeypressReturn.ogg
  09-14 07:48:55.665: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
  09-14 07:48:55.665: E/SoundPool(1273): error loading /system/media/audio/ui/KeypressInvalid.ogg
  09-14 07:48:55.665: W/AudioService(1273): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
 09-14 07:48:55.685: W/AudioService(1273): onLoadSoundEffects(), Error -1 while loading samples
 09-14 07:48:55.695: D/LightsService(1273): Excessive delay setting light: 223ms
 09-14 07:48:55.765: D/LightsService(1273): Excessive delay setting light: 65ms
 09-14 07:48:55.925: D/LightsService(1273): Excessive delay setting light: 98ms
  09-14 07:48:56.175: D/dalvikvm(3317): GC_FOR_ALLOC freed 176K, 8% free 3060K/3292K, paused 34ms, total 36ms
 09-14 07:48:56.535: V/GAV4(3317): Thread[GAThread,5,main]: Loaded clientId
 09-14 07:48:56.565: V/GAV4(3317): Thread[GAThread,5,main]: Loaded clientId
 09-14 07:48:56.565: V/GAV4(3317): Thread[GAThread,5,main]: putHit called
 09-14 07:48:56.575: V/GAV4(3317): Thread[GAThread,5,main]: Sending hit to service   PATH: https:  PARAMS: v=1,  ul=en-us,  t=screenview,  ht=1410695335608,  sr=620x808,  a=1297886004,  an=A,  tid=UA-xxxxxxxx-1,  aid=com.exampe.a,  cid=417c4fa3-d4c9-4eba-a560-3e7e46b65019,  av=1.0,  _u=.2nK-AL,  cd=MainActivity,  
09-14 07:48:56.715: D/dalvikvm(1385): GC_FOR_ALLOC freed 292K, 14% free 3938K/4568K, paused 105ms, total 109ms
09-14 07:48:56.785: W/GA-SERVICE(1385): Thread[Thread-242,5,main]:  Using destination https://ssl.google-analytics.com

      

Anyone can figure out what might be causing this problem?

+3


source to share


1 answer


The LogCate error message is another problem. However, the main problem is the following error message.

09-14 07:48:56.575: V/GAV4(3317): Thread[GAThread,5,main]: Sending hit to service   PATH: https:  PARAMS: v=1,  ul=en-us,  t=screenview,  ht=1410695335608,  sr=620x808,  a=1297886004,  an=A,  tid=UA-xxxxxxxx-1,  aid=com.exampe.a,  cid=417c4fa3-d4c9-4eba-a560-3e7e46b65019,  av=1.0,  _u=.2nK-AL,  cd=MainActivity,  
09-14 07:48:56.715: D/dalvikvm(1385): GC_FOR_ALLOC freed 292K, 14% free 3938K/4568K, paused 105ms, total 109ms
09-14 07:48:56.785: W/GA-SERVICE(1385): Thread[Thread-242,5,main]:  Using destination https://ssl.google-analytics.com

      



You can follow this tutorial: How to use the Google Analytics V4 API ...

I hope you solve this problem.

0


source







All Articles