Troubleshooting
Solutions for the most common issues when integrating Snapbug.
Network Security Configuration
Starting with Android 9 (API 28), cleartext (non-HTTPS) traffic is blocked by default. Since the Snapbug SDK communicates with the Desktop app over localhost using cleartext HTTP and WebSocket, you need to explicitly allow it.
1. Create a Network Security Config file
Create res/xml/network_security_config.xml in your app module:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">localhost</domain>
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config>2. Reference it in AndroidManifest.xml
<application
android:networkSecurityConfig="@xml/network_security_config"
... >
</application>Do not use cleartextTrafficPermitted="true" at the top level of the config. That would allow cleartext traffic to all domains, which is a security risk. Only allow it for localhost and 127.0.0.1.
If you already have a network_security_config.xml for other purposes (e.g., certificate pinning), just add the localhost and 127.0.0.1 domain entries to your existing file.
Debug-only configuration
If you want to restrict this to debug builds only, create separate manifest files:
src/debug/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:networkSecurityConfig="@xml/network_security_config" />
</manifest>Place the network_security_config.xml file in src/debug/res/xml/ instead of src/main/res/xml/.
Device Not Detected
If the Snapbug Desktop app does not detect your device:
- Check ADB -- Run
adb devicesand verify your device is listed. - Check port forwarding -- Run
adb forward tcp:9023 tcp:9023andadb forward tcp:9024 tcp:9024. - Restart ADB -- Run
adb kill-server && adb start-server. - Check the app is running -- The SDK only connects when the app with Snapbug initialized is in the foreground.
SDK Not Initializing
- Verify you called
Snapbug.initialize(this)in yourApplication.onCreate(). - Ensure the
Applicationclass is registered inAndroidManifest.xmlviaandroid:name. - Check that you are using
debugImplementation(notimplementation) for the SDK dependency.
Emulator Connection Issues
Emulators should connect automatically since they share localhost with the host machine. If not:
- Make sure the Desktop app is running before launching the emulator app.
- Try restarting the Desktop app.
- Check that no other process is using ports 9023 or 9024.
Wi-Fi Connection Not Working
When connecting over Wi-Fi:
- Both the device and the computer must be on the same network.
- Some corporate or guest networks block device-to-device communication. Try a different network or use USB instead.
- Verify the computer's local IP address is correct (use
ifconfigon macOS/Linux oripconfigon Windows).
ProGuard / R8 Issues
If you encounter issues with minified builds, add this to your ProGuard rules:
-keep class io.snapbug.sdk.** { *; }
-keep class ai.snapbug.** { *; }The no-op variant does not require ProGuard rules since it contains no code that needs to be preserved.