gpt4 book ai didi

Android 应用程序未向分析服务器发送命中

转载 作者:行者123 更新时间:2023-11-29 01:29:10 26 4
gpt4 key购买 nike

我正在尝试为我的一个应用程序实现谷歌分析,在尝试时文件中没有错误,但没有数据发送到服务器。

我在我的猫日志中发现了下面这行

W/GAv4﹕ AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.
W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.
I/MainActivity﹕ Setting screen name:
W/GAv4﹕ AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.

我的 list 文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dell.testanalytics" >

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:name=".AnalyticsApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<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>

需要跟踪的主要 Activity

package com.example.dell.testanalytics;


import java.util.Locale;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;


public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";

private ViewPager mViewPager;

private Tracker mTracker;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// [START shared_tracker]
// Obtain the shared Tracker instance.
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
// [END shared_tracker]

// Create the adapter that will return a fragment for each image.

// Set up the ViewPager with the pattern adapter.

// When the visible image changes, send a screen view hit.


// Send initial screen screen view hit.
sendScreenImageName();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}


private void sendScreenImageName() {


// [START screen_view_hit]
Log.i(TAG, "Setting screen name: ");
mTracker.setScreenName("Image~");
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
// [END screen_view_hit]
}

}

我的分析应用程序文件

  package com.example.dell.testanalytics;
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Logger;
import com.google.android.gms.analytics.Tracker;


public class AnalyticsApplication extends Application {
private Tracker mTracker;

synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);

mTracker = analytics.newTracker(R.xml.global_tracker);
}
return mTracker;
}
}

此外,我注意到全局 tracker.xml 文件是自动生成的,它不允许我创建我选择的全局 tracor。

需要您的帮助。

最佳答案

您可能需要在您的 androidmanifest 中添加这些设置

 <!-- Used for Google Play Store Campaign Measurement-->
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>

关于Android 应用程序未向分析服务器发送命中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32255928/

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