我刚刚按照本教程将Google Analytics SDK v4添加到Android应用中.现在的问题是,当我运行应用程序时,它只会在我设置跟踪的任何视图上显示黑屏.例如,下面是启动屏幕后第一个视图中的onCreate,onStart和onStop方法.启动画面加载很好,然后我在视图上得到一个黑屏.如果您注释掉分析代码,那么一切正常
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.landing_screen);
//Get a Tracker (should auto-report)
//Define font for use
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/cabinregular.otf");
//Set font to all elements
((TextView) findViewById(R.id.textFlat)).setTypeface(typeface);
((TextView) findViewById(R.id.textCool)).setTypeface(typeface);
((TextView) findViewById(R.id.textWarm)).setTypeface(typeface);
((TextView) findViewById(R.id.textPastels)).setTypeface(typeface);
((TextView) findViewById(R.id.textDecades)).setTypeface(typeface);
((TextView) findViewById(R.id.textNeutrals)).setTypeface(typeface);
((TextView) findViewById(R.id.textMidTones)).setTypeface(typeface);
//((TextView) findViewById(R.id.appHeaderText)).setTypeface(typeface);
//Create all the listeners to catch button presses
ImageButton buttonFlat = (ImageButton) findViewById(R.id.buttonFlat);
buttonFlat.setOnClickListener(this);
ImageButton buttonCool = (ImageButton) findViewById(R.id.buttonCool);
buttonCool.setOnClickListener(this);
ImageButton buttonWarm = (ImageButton) findViewById(R.id.buttonWarm);
buttonWarm.setOnClickListener(this);
ImageButton buttonPastels = (ImageButton) findViewById(R.id.buttonPastels); …Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序,我添加了谷歌分析跟踪器,它的工作原理(我可以看到分析面板中的视图).
问题是,有时应用程序开始加载然后卡住而不再响应.我试着调试它,我发现它涉及到这条线
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Run Code Online (Sandbox Code Playgroud)
有时候没有回应.
为什么会发生这种情况,我该如何解决?
编辑:
我添加了可选的analytics_global_config,它仍然会发生
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/analytics_global_config" />
Run Code Online (Sandbox Code Playgroud)
analytics_global_config.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_appName">HebConvertor</string>
<string name="ga_appVersion">1.0</string>
<string name="ga_logLevel">verbose</string>
<integer name="ga_dispatchPeriod">1000</integer>
<bool name="ga_dryRun">false</bool>
</resources>
Run Code Online (Sandbox Code Playgroud)
我的应用程序:
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
import android.app.Application;
public class MyApplication extends Application {
// The following line should be changed to include the correct property id.
private static final String PROPERTY_ID = "XX-XXXXXXXX-X";
public enum TrackerName {
APP_TRACKER, // Tracker used only in this app.
GLOBAL_TRACKER, // Tracker used by …Run Code Online (Sandbox Code Playgroud)