繁体   English   中英

适用于Android EasyTracker的Google Analytics V2 SDK会出错

[英]Google Analytics V2 SDK for Android EasyTracker giving errors

我已经按照此处针对Android的新Google Analytics V2 SDK的教程进行了操作:

https://developers.google.com/analytics/devguides/collection/android/v2/

不幸的是,无论何时我去运行应用程序,报告都不起作用,这是logcat给我的消息:

07-09 09:13:16.978: W/Ads(13933): No Google Analytics: Library Incompatible.
07-09 09:13:16.994: I/Ads(13933): To get test ads on this device, call adRequest.addTestDevice("2BB916E1BD6BE6407582A429D763EC71");
07-09 09:13:17.018: I/Ads(13933): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":0,"session_id":"7925570029955749351","u_sd":2,"seq_num":"1","slotname":"a14fd91432961bd","u_w":360,"msid":"com.mysampleapp.sampleapp","js":"afma-sdk-a-v6.0.1","mv":"8013013.com.android.vending","isu":"2BB916E1BD6BE6407582A429D763EC71","cipa":1,"format":"320x50_mb","net":"wi","app_name":"1.android.com.mysampleapp.sampleapp","hl":"en","u_h":592,"carrier":"311480","ptime":0,"u_audio":3});</script></head><body></body></html>
07-09 09:13:17.041: W/ActivityManager(220): Unable to start service Intent { act=com.google.android.gms.analytics.service.START (has extras) }: not found
07-09 09:13:17.049: W/GAV2(13933): Thread[main,5,main]: Connection to service failed 1
07-09 09:13:17.057: W/GAV2(13933): Thread[main,5,main]: Need to call initializea() and be in fallback mode to start dispatch.
07-09 09:13:17.088: D/libEGL(13933): loaded /system/lib/egl/libGLES_android.so
07-09 09:13:17.096: D/libEGL(13933): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
07-09 09:13:17.096: D/libEGL(13933): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
07-09 09:13:17.096: D/libEGL(13933): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so

这是我的代码(我已经编写了一些与httppost等有关的代码):

    package com.mysampleapp.sampleapp;

    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.ArrayList;
    import java.util.List;

    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.message.BasicNameValuePair;
    import org.json.JSONArray;
    import org.json.JSONObject;

    import com.google.analytics.tracking.android.EasyTracker;

    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnCancelListener;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.preference.PreferenceManager;
    import android.util.Log;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.ImageView;
    import android.widget.TextView;


    public class viewRandom extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.viewrandom);



            uservote.setVisibility(View.GONE);
            new randomViewClass().execute();

        }

        public void onStart() {
            super.onStart();
            EasyTracker.getInstance().activityStart(this);
        }

        public void onStop() {
            super.onStop();
            EasyTracker.getInstance().activityStop(this);
        }
}

我意识到这是一个老帖子,但我想提供一些更多的信息,这是我今天收到的完全相同的错误。

普林斯是完全正确的,它来自破折号。 对于大多数删除短划线和键入 - 再次将工作。 但是一旦你再次清理你的项目,它会将它切换回en_dash,这可能是mysho的问题。

由于Android Lint,它会自动执行此操作。 你可以禁用它!

进入你的偏好(我在Mac上,所以对我来说它是Eclipse - >首选项)

转到Android转到Lint错误检查

您可以完全禁用Lint检查器或执行我所做的操作,只禁用en_dash

要么在“可用性:排版”下搜索“TypographyDashes”,要么在搜索框内搜索“dash”。 无论哪种方式,它应该提出TypographyDashes。

突出显示它并在严重性下将其变为“忽略”

从那里单击“应用”,然后允许它重新连接

希望我能提供帮助

好的,我发现了这个问题。 它在我的analytics.xml文件中:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
    <string name="ga_trackingId">UA-0000000-00</string>
    <bool name="ga_autoActivityTracking">true</bool>
    <bool name="ga_reportUncaughtExceptions">true</bool>
    <string name="ga_sampleFrequency">20</string>
</resources>

发生的事情是当我将trackingId粘贴到文件中时,eclipse将其自动转换为“en dash”,Google无法正确读取我的trackingId。 将en破折号改为常规短划线工作正常,现在一切正常。

最好将属性添加到“resources”标记中,如下所示:

<?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-12345678-X</string>

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

  <!--Enable automatic exception tracking-->
  <bool name="ga_reportUncaughtExceptions">true</bool>
</resources>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM