gpt4 book ai didi

android - 谷歌分析未在 Android 应用程序中报告

转载 作者:行者123 更新时间:2023-11-30 01:39:35 24 4
gpt4 key购买 nike

我正在尝试使用本教程将 Google Analytics 实现到我的 Android 应用程序:https://developers.google.com/analytics/devguides/collection/android/v4/

在 Activity 中,我尝试发送事件,但我的 GA 配置文件中没有任何反应:

Dictum application = (Dictum) getApplication();
mTracker = application.getDefaultTracker();
mTracker.setScreenName("Main");
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("Tutorial")
.setAction("0")
.build());

list .xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="su.worldbest.dictum" >

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />




<application
android:name=".Dictum"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
...

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:1.2.3'
classpath 'com.google.gms:google-services:1.4.0-beta3'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

Build.gradle(模块:应用程序)

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


android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "su.worldbest.dictum"
minSdkVersion 14
targetSdkVersion 23
versionCode 2
versionName "1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.jjoe64:graphview:4.0.1'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.github.asne:asne-facebook:0.3.3'
compile 'com.github.asne:asne-instagram:0.3.3'
compile 'com.github.asne:asne-vk:0.3.3'
}

应用类:

public class Dictum extends Application {
private Tracker mTracker;

/**
* Gets the default {@link Tracker} for this {@link Application}.
* @return tracker
*/
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker(R.xml.analytics);
}
return mTracker;
}
}

分析.xml:

<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">

<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-XXXXXXXX-3</string>
//here i placed real track


<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>

<!--Disable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">false</bool>

</resources>

此外,我生成了 google-services.json 文件并将其放在/app 文件夹中。

我做错了什么?

最佳答案

改变:

mTracker = analytics.newTracker(R.xml.analytics);

收件人:

mTracker = analytics.newTracker(R.xml.global_tracker);
mTracker.enableAutoActivityTracking(true);
mTracker.enableExceptionReporting(false);

关于android - 谷歌分析未在 Android 应用程序中报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34679275/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com