我是一位新的Android开发者。我在我的应用中加入了Google分析。我的代码是一样的 https://stackoverflow.com/questions/25658269/google-analytics-tracker .....
我使用以下代码:
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());
}
});
}
我的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>
但是当我点击按钮时,它会显示以下错误:
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
有人可以看到可能导致此问题的原因吗?
答案 0 :(得分:0)
LogCate错误消息是另一个问题。但是,以下错误消息是主要问题。
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
您可以按照本教程:How to use Google Analytics API V4 ...
我希望你能解决这个问题。