Android SDK Documentation
1. Preparation
Dependencies
Ensure your Android project is compatible with the Quash SDK by setting the minSdkVersion
to 24 or higher. This requirement supports advanced functionalities such as session replay processing and encoding.
To resolve the Quash SDK dependency, your project needs access to the appropriate repositories. Add the following repository configuration to your project's build.gradle
(Project level):
pluginManagement {
repositories {
mavenCentral()
}
}
Next, add the Quash SDK to your project by including the following line in your build.gradle
(Module level) file:
implementation 'com.quashbugs:sherlock:1.0.9'
This setup ensures that your build environment can fetch and manage all necessary dependencies from Maven Central, Google's repository, and other specified sources, facilitating a smooth integration process.
2. SDK Initialization
Initialize the SDK at the beginning of your application's lifecycle, ideally in the onCreate
method of your Application
class:
Quash.initialize(
context = this,
applicationKey = "YOUR_APPLICATION_KEY",
shouldReadNetworkLogs = true
);
Parameters:
- Context (
this
): The application context. - Application Key: A unique identifier generated for your application, used to authenticate your app with Quash services.
- Network Logs Flag (
true
): Enables network logging to capture all network traffic, which can be crucial for debugging network-related issues.
3. Intercepting Network Requests
To intercept and log network requests and responses within your application, add Quash's network interceptor directly to your OkHttpClient
configuration. Here's how you can set it up:
val builder = OkHttpClient.Builder()
Quash.getInstance().networkInterceptor?.let { interceptor ->
builder.addInterceptor(interceptor)
}
val client = builder.build()
This setup configures your OkHttpClient
to capture all network transactions, which are essential for debugging network issues. Integrating the interceptor directly ensures that every network request and response goes through Quash, allowing for detailed logging and analysis in your bug reports.
4. Activation Mechanics
Quash SDK is activated by a default gesture: shaking the device. This gesture brings up the bug-reporting interface, allowing quick and easy bug reporting.
5. Troubleshooting
Here are quick fixes for some common issues you might encounter with the Quash SDK:
SDK Initialization Fails:
- Issue: Error messages about an invalid application key.
- Fix: Double-check the application key for accuracy and network accessibility.
Network Interceptor Not Working:
- Issue: No network data being logged.
- Fix: Confirm that the interceptor is added to your
OkHttpClient
and used consistently across your app.
Application Crashes on Start:
- Issue: Crashes immediately after SDK integration.
- Fix: Check for library compatibility issues and ensure Quash SDK version matches your other dependencies.
Network Permissions Denied:
- Issue: Necessary network permissions are missing.
- Fix: Add
INTERNET
andACCESS_NETWORK_STATE
permissions to your AndroidManifest.xml.
Congratulations! You've successfully set up the Quash SDK in your Android project. With Quash integrated, you're now equipped to capture detailed logs of network transactions, handle crashes more effectively, and streamline your debugging process with enhanced reporting tools. If you encounter any issues or have questions, our support team is ready to assist you. Happy debugging, and here's to building bug-free applications with ease!