我正在将我的应用从使用Google Analytics迁移到Google Analytics for Firebase。
我按照教程https://firebase.google.com/docs/android/setup设置了Firebase项目。然后我按照以下方式设置了Analytics:https://firebase.google.com/docs/analytics/android/start/
我使用以下命令启用了日志记录:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
我现在使用下面的命令来查看 DebugView 中的事件(https://support.google.com/firebase/answer/7201382?hl=zh-Hans&authuser=0):
adb shell setprop debug.firebase.analytics.app com.myapp.mypackage
所有的构建和编译都完成了,但当我在设备上运行应用程序时,我看到以下日志:
09-17 20:32:48.248 21705-21751/com.myapp.mypackage I/FirebaseInitProvider: FirebaseApp initialization successful
09-17 20:32:48.318 21705-21751/com.myapp.mypackage I/FA: App measurement is starting up, version: 18202
09-17 20:32:48.318 21705-21751/com.myapp.mypackage I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
09-17 20:32:48.318 21705-21751/com.myapp.mypackage I/FA: Faster debug mode event logging enabled. To disable, run:
adb shell setprop debug.firebase.analytics.app .none.
09-17 20:32:48.328 21705-21751/com.myapp.mypackage D/FA: Debug-level message logging enabled
09-17 20:32:48.548 21705-21763/com.myapp.mypackage I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtilLight.isUninstalledAppPossiblyUpdating
09-17 20:32:48.568 21705-21763/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:32:48.648 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:32:48.658 21705-21705/com.myapp.mypackage D/AppFirebaseAnalytics: setUserProperty: upKey: BuildType -> upValue: debug
09-17 20:32:48.668 21705-21705/com.myapp.mypackage D/AppFirebaseAnalytics: setUserProperty: upKey: AppAnalyticsVersion -> upValue: 2.0
09-17 20:32:48.788 21705-21751/com.myapp.mypackage D/FA: Setting user property (FE): BuildType, debug
09-17 20:32:49.018 21705-21751/com.myapp.mypackage D/FA: Setting user property (FE): AppAnalyticsVersion, 2.0
09-17 20:32:49.668 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:32:49.678 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to send app launch
09-17 20:32:49.688 21705-21751/com.myapp.mypackage E/FA: Failed to get app instance id
09-17 20:32:49.688 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to set user attribute
09-17 20:32:49.688 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to set user attribute
09-17 20:32:49.688 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to set user attribute
09-17 20:32:49.878 21705-21751/com.myapp.mypackage I/FA: Tag Manager is not found and thus will not be used
09-17 20:32:50.138 21705-21751/com.myapp.mypackage D/FA: Logging event (FE): screen_view(_vs), Bundle[{ga_event_origin(_o)=auto, ga_screen_class(_sc)=AppBootActivity, ga_screen_id(_si)=3005854567277075178}]
09-17 20:32:50.288 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:32:50.288 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:32:50.298 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:32:50.308 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:32:50.318 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:32:50.318 21705-21751/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:32:50.318 21705-21751/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:32:54.668 21705-21751/com.myapp.mypackage D/FA: Logging event (FE): screen_view(_vs), Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=AppBootActivity, ga_previous_id(_pi)=3005854567277075178, ga_screen_class(_sc)=ScreenLauncherActivity, ga_screen_id(_si)=3005854567277075179}]
09-17 20:32:54.768 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:32:56.948 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:32:56.958 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:32:56.958 21705-21751/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:32:56.968 21705-21751/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:33:19.048 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:33:19.138 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:33:19.148 21705-21751/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:33:22.708 21705-21705/com.myapp.mypackage D/AppFirebaseAnalytics: logEvent: eventName: Screen_Launcher -> infoBundle: Bundle[{action=Expand, label=temperatures}]
09-17 20:33:22.768 21705-21751/com.myapp.mypackage D/FA: Logging event (FE): Screen_Launcher, Bundle[{action=Expand, ga_event_origin(_o)=app, ga_screen_class(_sc)=ScreenLauncherActivity, ga_screen_id(_si)=3005854567277075179, label=temperatures}]
09-17 20:33:22.818 21705-21751/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:33:22.908 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:33:22.918 21705-21751/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:38:22.738 21705-23662/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:38:22.778 21705-23662/com.myapp.mypackage D/FA: Logging event (FE): user_engagement(_e), Bundle[{ga_event_origin(_o)=auto, engagement_time_msec(_et)=303709, ga_screen_class(_sc)=ScreenLauncherActivity, ga_screen_id(_si)=3005854567277075179}]
09-17 20:38:22.798 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:38:23.118 21705-23662/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:38:23.128 21705-23662/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:38:23.128 21705-23662/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:38:23.158 21705-23662/com.myapp.mypackage D/FA: Logging event (FE): screen_view(_vs), Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=ScreenLauncherActivity, ga_previous_id(_pi)=3005854567277075179, ga_screen_class(_sc)=ScreenSaverActivity, ga_screen_id(_si)=3005854567277075180}]
09-17 20:38:23.178 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:38:23.208 21705-23662/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:38:23.218 21705-23662/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:38:23.218 21705-23662/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:38:23.258 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:39:08.618 21705-21705/com.myapp.mypackage D/AppFirebaseAnalytics: logEvent: eventName: Standby -> infoBundle: Bundle[{action=Click, label=Standby}]
09-17 20:39:08.668 21705-23896/com.myapp.mypackage D/FA: Logging event (FE): Standby, Bundle[{action=Click, ga_event_origin(_o)=app, ga_screen_class(_sc)=ScreenSaverActivity, ga_screen_id(_si)=3005854567277075180, label=Standby}]
09-17 20:39:08.728 21705-23896/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:39:08.808 21705-23896/com.myapp.mypackage D/FA: Logging event (FE): screen_view(_vs), Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=ScreenSaverActivity, ga_previous_id(_pi)=3005854567277075180, ga_screen_class(_sc)=ScreenLauncherActivity, ga_screen_id(_si)=3005854567277075179}]
09-17 20:39:08.848 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-17 20:39:08.878 21705-23896/com.myapp.mypackage W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 4325038
09-17 20:39:08.898 21705-23896/com.myapp.mypackage D/FA: Logging event (FE): user_engagement(_e), Bundle[{ga_event_origin(_o)=auto, engagement_time_msec(_et)=45904, ga_screen_class(_sc)=ScreenSaverActivity, ga_screen_id(_si)=3005854567277075180}]
09-17 20:39:08.948 21705-23896/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:39:08.948 21705-23896/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:39:08.948 21705-23896/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:39:08.948 21705-23896/com.myapp.mypackage E/FA: Failed to send current screen to service
09-17 20:39:08.948 21705-23896/com.myapp.mypackage E/FA: Discarding data. Failed to send event to service
09-17 20:39:09.178 21705-21705/com.myapp.mypackage W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
在 Firebase 控制台的 DebugView 中没有任何事件。
每次执行记录事件的操作时,都会出现 Google Play 服务相关的错误。
应用程序运行所在的设备并未部署到 Play 商店中,因此可能存在 Google Play 服务版本过旧甚至不存在的情况,我们不想强制用户更新/安装它。
从日志中看,FirebaseApp 初始化成功,但是随后会有一个日志显示“无法获取应用实例 ID”...
我进行了一些研究,在某些情况下,我发现 Firebase Analytics 需要更新 Google Play 服务 (https://dev59.com/5Zffa4cB1Zd3GeqP7GA2#37426991),但在其他情况下,它似乎应该能够正常工作:
- https://blog.novoda.com/firebase-on-amazon-devices/
- https://github.com/firebase/quickstart-unity/issues/223#issuecomment-520908309
我的问题是:
- 我可以在没有 Google Play 服务或具有过时版本的情况下使用 Firebase Analytics 吗?
- 如果可以,可能会出现什么问题?是否需要进行某些配置?