Android — AnalyticsReceiver не зарегистрирован или отключен?

Я использую аналитику Google, но когда я отлаживаю с помощью adb, мне показывают эти сообщения.

05-11 14:57:48.911 1681-1912/? W/GAv4-SVC: Network compressed POST connection error: java.net.ConnectException: failed to connect to ssl.google-analytics.com/127.0.0.1 (port 443) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)
05-11 14:58:43.591 7281-7281/? I/GAv4: Google Analytics 8.2.98 is starting up. To enable debug logging on a device run:
                                         adb shell setprop log.tag.GAv4 DEBUG
                                         adb logcat -s GAv4
05-11 14:58:43.631 7281-7281/? W/GAv4: AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See some url for instructions.
05-11 14:58:43.681 7281-7281/? D/GAv4: setLocalDispatchPeriod (sec): 60
05-11 14:58:43.681 7281-7330/? W/GAv4: AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See some url for instructions.
05-11 14:58:48.131 7237-7268/? I/GAV3: Thread[GAThread,5,main]: No campaign data found.
05-11 14:59:23.171 7761-7785/? I/GAv4: Google Analytics 8.1.15 is starting up. To enable debug logging on a device run:
                                         adb shell setprop log.tag.GAv4 DEBUG
                                         adb logcat -s GAv4
05-11 14:59:23.181 7761-7785/? W/GAv4: AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See some url for instructions.
05-11 14:59:23.191 7761-7785/? W/GAv4: CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See some url for instructions.
05-11 14:59:23.191 7761-7791/? W/GAv4: AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See some url for instructions.
05-11 14:59:23.591 7817-7817/com.example.admin.helloanalytics I/GAv4: Google Analytics 8.4.87 is starting up. To enable debug logging on a device run:
                                                                        adb shell setprop log.tag.GAv4 DEBUG
                                                                        adb logcat -s GAv4
05-11 14:59:23.591 7817-7817/com.example.admin.helloanalytics D/GAv4: XML config - app name: XXXXX
05-11 14:59:23.591 7817-7817/com.example.admin.helloanalytics D/GAv4: XML config - app version: 1.0
05-11 14:59:23.591 7817-7817/com.example.admin.helloanalytics D/GAv4: XML config - dispatch period (sec): 1800
05-11 14:59:23.591 7817-7817/com.example.admin.helloanalytics D/GAv4: XML config - dry run: false
05-11 14:59:23.601 7817-7817/com.example.admin.helloanalytics D/GAv4: setLocalDispatchPeriod (sec): 1800
05-11 14:59:23.881 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit delivery requested: ht=1462962563740, _s=50, _v=ma8.4.87, a=2122668187, adid=7d85460d-4d41-4d41-8225-b1499b154b44, aid=com.example.admin.helloanalytics, an=XXXXX, ate=1, av=1.0, cd=com.example.admin.helloanalytics.MainActivity, cid=577d2178-6c7e-431d-a258-cea382dd9263, sr=540x960, t=screenview, tid=UA-77544180-1, ul=en-us, v=1
05-11 14:59:23.921 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit delivery requested: ht=1462962563740, _s=51, _v=ma8.4.87, a=2122668188, adid=7d85460d-4d41-4d41-8225-b1499b154b44, aid=com.example.admin.helloanalytics, an=XXXXX, ate=1, av=1.0, cd=com.example.admin.helloanalytics.MainActivity, cid=577d2178-6c7e-431d-a258-cea382dd9263, sc=start, sr=540x960, t=screenview, tid=UA-77544180-1, ul=en-us, v=1
05-11 14:59:23.991 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit sent to the device AnalyticsService for delivery
05-11 14:59:24.531 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit sent to the device AnalyticsService for delivery
05-11 14:59:24.801 7915-7915/? W/GAV2: Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
05-11 14:59:25.151 7964-7964/? I/GAv4: Google Analytics 8.2.98 is starting up. To enable debug logging on a device run:
                                         adb shell setprop log.tag.GAv4 DEBUG
                                         adb logcat -s GAv4
05-11 14:59:25.161 7964-7964/? W/GAv4: AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See some url for instructions.
05-11 14:59:25.191 7964-7964/? D/GAv4: setLocalDispatchPeriod (sec): 60
05-11 14:59:25.191 7964-8007/? W/GAv4: AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See some url for instructions.
05-11 14:59:29.771 7915-7955/? I/GAV2: Thread[GAThread,5,main]: No campaign data found.
05-11 14:59:49.111 1681-1912/? W/GAv4-SVC: Network compressed POST connection error: java.net.ConnectException: failed to connect to ssl.google-analytics.com/127.0.0.1 (port 443) after 60000ms: isConnected failed: ECONNREFUSED (Connection refused)
05-11 15:00:12.531 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit delivery requested: ht=1462962612433, _s=52, _v=ma8.4.87, a=2122668189, adid=7d85460d-4d41-4d41-8225-b1499b154b44, aid=com.example.admin.helloanalytics, an=XXXXX, ate=1, av=1.0, cd=com.example.admin.helloanalytics.MainActivity, cid=577d2178-6c7e-431d-a258-cea382dd9263, ea=Share, ec=Action, sr=540x960, t=event, tid=UA-77544180-1, ul=en-us, v=1
05-11 15:00:12.621 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit sent to the device AnalyticsService for delivery
05-11 15:00:12.671 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit delivery requested: ht=1462962612569, _s=53, _v=ma8.4.87, a=2122668189, adid=7d85460d-4d41-4d41-8225-b1499b154b44, aid=com.example.admin.helloanalytics, an=XXXXX, ate=1, av=1.0, cd=com.example.admin.helloanalytics.Second, cid=577d2178-6c7e-431d-a258-cea382dd9263, sr=540x960, t=screenview, tid=UA-77544180-1, ul=en-us, v=1
05-11 15:00:12.691 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit delivery requested: ht=1462962612569, _s=54, _v=ma8.4.87, a=2122668190, adid=7d85460d-4d41-4d41-8225-b1499b154b44, aid=com.example.admin.helloanalytics, an=XXXXX, ate=1, av=1.0, cd=com.example.admin.helloanalytics.Second, cid=577d2178-6c7e-431d-a258-cea382dd9263, sr=540x960, t=screenview, tid=UA-77544180-1, ul=en-us, v=1
05-11 15:00:12.751 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit sent to the device AnalyticsService for delivery
05-11 15:00:12.791 7817-7872/com.example.admin.helloanalytics D/GAv4: Hit sent to the device AnalyticsService for delivery

Моя аналитика Google подключается или это правда?

Вот моя основная активность:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;

public class MainActivity extends AppCompatActivity {
    private Tracker mTracker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button BTN = (Button) findViewById(R.id.BTN);
        BTN.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTracker.send(new HitBuilders.EventBuilder()
                        .setCategory("Action")
                        .setAction("Share")
                        .build());
                Intent intent = new Intent(MainActivity.this,Second.class);
                startActivity(intent);
            }
        });


        MobikulApplication mMobikulApplication = (MobikulApplication) getApplication();
        mTracker = mMobikulApplication.getDefaultTracker();

        String name = this.getClass().getName();
        mTracker.setScreenName("" + name);
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
    }
}

А вот мой analytics_global_config.xml:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
    <!-- The application name. Defaults to name specified for the application label -->
    <string name="ga_appName">XXXXX</string>

    <!-- The application version. Defaults to android:versionName specified in the
      AndroidManifest.xml -->
    <string name="ga_appVersion">1.0</string>

    <!-- The dispatching period in seconds when Google Play services is unavailable. The
    default period is 1800 seconds or 30 minutes -->
    <integer name="ga_dispatchPeriod">1800</integer>

    <!-- Enable dry run mode. Default is false -->
    <bool name="ga_dryRun">false</bool>
</resources>

И я добавляю json в свой проект приложения.

Если нужно посмотреть весь проект, могу показать.

Спасибо


person Community    schedule 11.05.2016    source источник
comment
Проверьте эту ссылку: stackoverflow.com/questions/30154057/   -  person KinGPinG    schedule 15.12.2016


Ответы (2)


Убедитесь, что вы включили AnalyticService в Manifest.

   <service android:name="com.google.android.gms.analytics.AnalyticsService"
            android:enabled="true"
            android:exported="false"/>

И вы не указали GA_PROPERTY_ID (идентификатор отслеживания) в analytics_global_config.xml

вы не можете отследить без идентификатора

Изменить: обмен образцами

EventLogUtil.class

public class EventLogUtil {

    private static final String TAG = EventLogUtil.class.getSimpleName();
    private FirebaseAnalytics firebaseAnalytics;
    private static EventLogUtil eventLogUtil;

    /**
     * Param names can be up to 40 characters long, may only contain alphanumeric characters and
     * underscores ("_"), and must start with an alphabetic character. Param values can be up to
     * 100 characters long. The "firebase_", "google_" and "ga_" prefixes are reserved and should
     * not be used.
     * https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param
     */
    private static final int FIRE_BASE_MAX_KEY_EVENT_LENGTH = 40;
    private static final int FIRE_BASE_MAX_VALUE_EVENT_LENGTH = 100;
    private static final int FIRE_BASE_MAX_USER_PROPERTY_LENGTH = 36;

    private EventLogUtil() {
    }

    private EventLogUtil(Context context) {
        if (firebaseAnalytics == null) {
            firebaseAnalytics = FirebaseAnalytics.getInstance(context);
        }
    }

    public static EventLogUtil getInstance(Context context) {
        if (eventLogUtil == null) {
            eventLogUtil = new EventLogUtil(context);
        }
        return eventLogUtil;
    }

    public void logEvent(String eventName,
                         Map<String, String> eventParams) {
        CustomEvent customEvent = new CustomEvent(eventName);
        Bundle params = new Bundle();
        if (eventParams != null && !eventParams.isEmpty()) {
            eventParams.put("time_stamp", getCurrentUTCTime("MM/dd/yyyy h:mm:ss a"));
            for (Map.Entry<String, String> entry : eventParams.entrySet()) {
                String key = entry.getKey();
                String value = entry.getValue();
                key = removeExceedingCharacters(key, FIRE_BASE_MAX_KEY_EVENT_LENGTH);
                value = removeExceedingCharacters(value, FIRE_BASE_MAX_VALUE_EVENT_LENGTH);
                customEvent.putCustomAttribute(key, value);
                params.putString(key, value);
            }
        }
        firebaseAnalytics.logEvent(eventName, params);
        Answers.getInstance().logCustom(customEvent);
    }

    public void setUserProperties(User user) {
        try {
            String baseJid = "anyID";
            firebaseAnalytics.setUserId(baseJid);
            firebaseAnalytics.setUserProperty("UserJid",
                    removeExceedingCharacters(baseJid, FIRE_BASE_MAX_USER_PROPERTY_LENGTH));
            firebaseAnalytics.setUserProperty("UserName",
                    removeExceedingCharacters(user.getFullName(), FIRE_BASE_MAX_USER_PROPERTY_LENGTH));
        } catch (Exception e) {
            LogUtils.d(TAG, e.getMessage());
        }
    }

    public void setAnalyticsCollectionStatus(boolean status) {
        firebaseAnalytics.setAnalyticsCollectionEnabled(status);
    }

    public void trackCurrentScreen(Activity activity, String screenName) {
        firebaseAnalytics.setCurrentScreen(activity, screenName, null);
        Answers.getInstance().logContentView(new ContentViewEvent()
                .putContentName(screenName)
                .putContentType("Screen View")
                .putContentId("screen-activity"));
    }

    public void trackException(Exception e) {
        FirebaseCrash.report(e);
    }

    public static String getCurrentUTCTime(String dateFormat) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return simpleDateFormat.format(new Date());
    }

    public static String removeExceedingCharacters(final String string, final int maxLength) {
        try {
            if (string != null &&
                    !string.isEmpty() &&
                    string.length() > maxLength) {
                return string.substring(0, maxLength);
            }
        } catch (Exception e) {
            LogUtils.d(TAG, e.getMessage());
        }
        return string;
    }
}

А для включения ткани см. это

назови это как

HashMap<String, String> hashForAnalytics = new HashMap<>();
hashForAnalytics.put(SOAP_SERVICE_EVENT_FAILURE, FALSE_RESPONSE + " " + serviceName);
EventLogUtil.getInstance(context).logEvent(SOAP_SERVICE_EVENT, hashForAnalytics);
person AndroidGeek    schedule 15.06.2016

Если вы используете устройство с сервисами Google Play, отправка осуществляется автоматически. Дополнительные сведения см. в руководстве по диспетчеризации Analytics для Android:

https://developers.google.com/analytics/devguides/collection/android/v4/dispatch

person Tiem Song    schedule 11.05.2016