2012-07-09 72 views
11

我跟了位于此处查看新的谷歌Analytics(分析)V2 SDK为Android教程:谷歌Analytics(分析)V2 SDK为Android的EasyTracker给错误

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); 
     } 
} 
+0

我越来越没有理由,我可以看到同样的错误,但该SDK工作正常。 – vitriolix 2012-07-25 00:45:43

+0

我有同样的问题,但我不知道如何将“en_dash”更改为常规短划线。 – mysho 2012-07-23 14:12:42

+0

只需删除短划线字符并将其替换为短划线字符 – 2012-07-26 01:03:03

回答

4

好的我发现了这个问题。这是我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到文件中,蚀了它会自动转换为一个“破折号”和谷歌无法正确读取我的trackingId。更改破折号为常规破折号运作良好,现在一切正常运作。

+0

这里的“常规”是什么意思,是'破折号'的ASCII和'正常破折号'的UTF格式? – thecr0w 2013-06-04 11:24:50

9

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

王子是完全正确的,它是从破折号。对于大多数删除破折号和输入 - 再次将工作。 但是,一旦你再次清理你的项目,它会切换回en_dash这可能是mysho的问题。

它会自动执行,因为Android Lint。尽管你可以禁用它!

Go into your preferences (I'm on a mac so for me it's Eclipse -> Preferences)

Go to Android Go to Lint error Checking

You can either disable Lint checker completely or do what I did, disable just the en_dash thing

Either fine the one called "TypographyDashes" under Usability:Typography or search "dash" inside the search box. Either way it should come up with TypographyDashes.

Highlight it and turn it to "Ignore" under the severity

From there Click apply and then allow it to relint

希望我能帮助

+0

搜索了超过5个小时后,如何用破折号解决这个问题,没有人比你更特别的比Travis更优雅。我希望我可以给你+10 upvotes! – pbojinov 2012-11-12 01:37:31

+0

一旦你再次清理你的项目,它会将它切换回en_dash < - 这是我的问题,因为我正在改变它,然后做一个干净的,这只会恢复它。希望也能帮助别人 – pbojinov 2012-11-12 01:38:34

4

最好是一个属性添加到“资源”标签象下面这样:

<?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> 
相关问题