Sub topic 7
Turning on debug mode in Android and iOS apps
This chapter assumes you have read the chapters on the Realtime report and on how debug_mode flags events. It also assumes you have a GA4 property linked to a Firebase app (Android, iOS, or both), the app's source or a debug build, and a device or emulator you can run it on. Command-line steps need the Android SDK platform tools (adb) or Xcode.
Why mobile apps need a separate switch
On the web, gtag.js lets you add debug_mode to a config or event call. Mobile apps send events through the Firebase Analytics SDK, which has no such parameter on its public logging calls. Instead, you switch debug mode on for the whole app process, using a system property on Android or a launch argument on iOS.
There is also a timing difference. In normal operation the SDK batches events and uploads them roughly once an hour to save battery and data. With debug mode on, the SDK uploads each event almost immediately and flags it as debug traffic. DebugView then shows the device as a selectable debug device, and events appear within a few seconds.
Enabling debug mode on Android
Android debug mode is controlled by a system property named debug.firebase.analytics.app. Its value is the application ID (package name) of the app you want to debug. Connect a device with USB debugging enabled, or start an emulator, then run:
# Turn on debug mode for one app
adb shell setprop debug.firebase.analytics.app com.example.myapp
# Turn it off again
adb shell setprop debug.firebase.analytics.app .none.Replace com.example.myapp with your own application ID. If you use build variants such as .debug suffixes, use the exact ID of the installed build, for example com.example.myapp.debug. A mismatch is the most common reason nothing appears.
Three behaviors matter in practice:
- The setting persists until you change it. Restarting the app does not clear it, so you do not repeat the command for each test run.
- The property is only read when the app process starts. If the app is already running, force-stop it and reopen it after setting the property.
- You must turn it off yourself. Forgetting leaves that device sending flagged traffic to the property until you run the
.none.command.
If several devices or emulators are connected, adb refuses the command. Pick one by serial number:
adb devices
adb -s emulator-5554 shell setprop debug.firebase.analytics.app com.example.myappTo confirm the value took effect, read it back:
adb shell getprop debug.firebase.analytics.appThe output should be your package name. An empty line or .none. means debug mode is off.
Enabling debug mode on iOS
On iOS the switch is a launch argument passed to the app. In Xcode:
- Choose Product > Scheme > Edit Scheme.
- Select Run in the left column, then open the Arguments tab.
- Under Arguments Passed On Launch, add
-FIRAnalyticsDebugEnabled. - Close the dialog and run the app on a simulator or a device.
To turn debug mode off, either remove the argument or replace it with -FIRAnalyticsDebugDisabled. Because the argument lives in the scheme, it applies only to launches from Xcode using that scheme. An app that a tester installs from TestFlight or the App Store has no such argument and sends normal, batched traffic.
For simulators you can also launch from the command line. Arguments after the bundle ID go to the app:
xcrun simctl launch booted com.example.myapp -FIRAnalyticsDebugEnabledHere booted means the currently running simulator, and com.example.myapp is your bundle identifier.
Cross-platform frameworks
Flutter, React Native, Unity, and similar frameworks send analytics through the native Firebase SDKs underneath. Use the same switches for the platform you are running:
| Framework layer | What to use |
|---|---|
| Flutter on Android | The `adb setprop` command for the app's application ID |
| Flutter on iOS | The scheme launch argument in the `Runner` scheme |
| React Native | Same as native: `adb` on Android, scheme argument on iOS |
| Unity | Same as native, applied to the exported Android or Xcode project |
For Flutter, the iOS scheme is edited in ios/Runner.xcworkspace, not in the Dart code.
Seeing what the SDK is doing: verbose logging
When an event is missing, you often need to know whether the SDK logged it at all. Verbose logging prints each logged event and each upload to the device log.
On Android, enable the log tags, restart the app, and read the log:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVCLook for lines that mention Logging event followed by the event name and parameters, and for upload lines that show a successful response. A Logging event line proves your code called the SDK. A missing upload line suggests a network or configuration problem.
On iOS, add a second launch argument next to the debug one: -FIRAnalyticsVerboseLoggingEnabled. Output appears in the Xcode console, with lines tagged [FirebaseAnalytics].
Checking the result in DebugView
After enabling debug mode and launching the app:
- In GA4, open Admin > Data display > DebugView. The same view is also available in the Firebase console under Analytics > DebugView.
- Open the Debug Device selector at the top left. Your device appears under its model name or a device ID.
- Select it, then interact with the app. Events appear in the minute-by-minute stream within a few seconds.
If more than one device is in debug mode, pick the one you are testing from the selector. DebugView only lists devices that sent debug-flagged traffic within roughly the last 30 minutes.
Common mobile problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Device never appears in the selector | Wrong package name in `setprop`, or the app was not restarted | Check with `getprop`, force-stop the app, relaunch |
| Works from Xcode, not from a TestFlight build | The launch argument exists only in the Xcode scheme | Test from Xcode, or use a debug build on the device |
| Events show in DebugView but not in standard reports | Normal processing delay, or a Developer traffic filter excluding debug traffic | Wait, and check the filter state under Admin > Data collection and modification > Data filters |
| Device appears for the wrong app | Several apps share a device and only one ID is set | Set the property for the app you are testing, and use the right data stream |
| Everything from your phone is flagged weeks later | You left debug mode on | Run the `.none.` command or remove the scheme argument |
| Nothing is logged, and verbose log shows no `Logging event` | The event call is not executed, or analytics collection is disabled in the app | Check your code path and any opt-out setting for analytics collection |
A short test routine for mobile
- Set debug mode for the exact build ID, using
adbor the Xcode scheme argument. - Force-stop and relaunch the app.
- Open DebugView and select the device.
- Trigger one interaction and look for its event, for example a
sign_upevent with amethodparameter. - Turn debug mode off when finished on Android, using the
.none.command.
Exercise
You set adb shell setprop debug.firebase.analytics.app com.example.myapp while the app was already open, and the device still does not appear in DebugView. Give two likely causes and the fix for each.
Show answer
First, the app reads the property only when its process starts, so the running process never saw it. Force-stop the app and reopen it. Second, the package name may not match the installed build, for example a debug build with the ID com.example.myapp.debug. Check with adb shell getprop debug.firebase.analytics.app, correct the ID with setprop, and relaunch.
Exercise
A tester installs your iOS app from TestFlight and reports that nothing shows in DebugView, even though it works when you run from Xcode. Why, and what could the tester use instead?
Show answer
The -FIRAnalyticsDebugEnabled argument is stored in your Xcode scheme and applies only to launches from Xcode. A TestFlight install has no launch argument, so it sends normal batched traffic, not debug traffic. The tester should run a build launched from Xcode with the argument, or you can verify the same events in Realtime, which shows normal traffic.