Guide for AI Coding Agents to Integrate Luciq on Android

Guide for AI Coding Agents to Integrate Luciq on Android

⚠️ UNIVERSAL EXECUTION RULES ⚠️

Critical Rules - Apply to ALL Platforms:

  • NEVER skip WAIT instructions - always get user confirmation before proceeding

  • NEVER auto-execute optional steps - user must explicitly select them

  • ALWAYS fetch latest SDK version before integration (DO NOT use placeholders like 1.0.0)

  • ALL API parameters must be included (can be nil/null) - never omit parameters

Execution Guidelines:

  • Be specific and concise - save tokens by being to the point

  • Don't create documentation files - only code files required for integration

  • Implement mandatory steps sequentially - complete each before moving to the next

  • Prompt user with current step - describe what's happening, then proceed when done

  • Only ask for optional steps after mandatory ones - show numbered list for selection

  • Use numbered lists for all options - makes selection easier (e.g., "Select 1", "Select 2")

  • Add wrap up step - execute validation only when user selects "Wrap up & validate"

  • Check documentation first - confirm API availability before getting creative beyond examples

Official Documentation:

  • Main docs: https://docs.luciq.ai/

  • Always check official docs when unsure about API signatures or platform specifics


Integration Workflow Overview


Step 1 — Collect Required Information [MANDATORY]

1A: Get App Token

Check MCP Server First:

Validation:

  • Token should be non-empty

  • Typically 32-40 character hexadecimal string

  • If invalid format, warn user but proceed


1B: Determine Integration Method

Auto-Detection Logic:

Platform-specific detection should look for:

  • iOS: Podfile, Cartfile, SPM packages in .xcodeproj, or none → Manual

  • Android: build.gradle with repositories, pom.xml, or none → Manual


1C: Apply Default Configuration (Inform + Opt-in)

Default configuration is applied automatically. Inform the user:

Store default configuration:

If user wants to customize (yes):

If user does not want to customize (no):

  • Proceed to Step 2


Step 2 — Add SDK Dependency [MANDATORY - Platform-Specific]

Pre-Dependency Critical Step:

⚠️ MUST FETCH LATEST VERSION FIRST:

Then proceed to platform-specific dependency installation (see platform guides)


Step 3 — Initialize the SDK [MANDATORY - Platform-Specific]

Invocation Events Configuration

Default invocation events: [shake, floatingButton]

These are applied automatically unless the user chose to customize in Step 1C.

If user chose to customize invocation events:

Invocation Event Mapping:

  • none → Empty array []

  • Single selection → [selected]

  • Multiple → [event1, event2, ...]

Apply configuration in platform-specific syntax (see platform guides)


Step 4 — Configure Network Logging [MANDATORY]

Concepts (Platform-Agnostic):

Purpose: Automatically capture network requests/responses and optionally mask sensitive data

Part A: Network Capture

Part B: Mask Sensitive Data

Implementation Requirements:

  • Masking code MUST be placed AFTER SDK initialization

  • Headers: Simple loop through header names

  • Body: Recursive function to handle nested JSON at any depth

  • Performance: Use Set/HashSet for O(1) field lookup


Step 5 — Mask Repro Step Screenshots [MANDATORY]

Concepts (Platform-Agnostic):

Purpose: Automatically blur/mask sensitive UI elements in screenshot repro steps

Default Configuration:

  • iOS: maskNothing (with guidance comments for customization)

  • Android: All types (textInputs, labels, media)

If user chose to customize in Step 1C:

Available Mask Types:

  • iOS:

    • .textInputs: Text input fields, password fields

    • .labels: Text labels, buttons with text

    • .media: Comprehensive masking (includes all types)

    • .maskNothing: No automatic masking (default)

  • Android:

    • MaskingType.TEXT_INPUTS: Text input fields, password fields

    • MaskingType.LABELS: Text labels, buttons with text

    • MaskingType.MEDIA: Images, media content

    • MaskingType.MASK_NOTHING: Disable auto masking


Step 6 — Upload Symbolication Files [MANDATORY]

Concepts (Platform-Agnostic):

Purpose: Upload debug symbols (dSYM for iOS, mapping files for Android) for crash symbolication. This is required for readable crash reports.

iOS (dSYM Upload):

Detection-based approach:

See ios-guide.md for implementation details.

Android (Mapping File Upload):

Default: Gradle task (automatic)

See android-guide.md for implementation details.

Customization Options:


🛑 MANDATORY STEPS COMPLETE - STOP HERE


Optional Steps Menu

After all mandatory steps are complete, display:


Optional Step 1 — Configure Repro Steps Mode

Concepts (Platform-Agnostic):

Purpose: Control which products include screenshots in their repro steps

Default Behavior:

  • Bug Reporting: Screenshots enabled

  • Crash Reporting: Screenshots disabled

  • Session Replay: Screenshots enabled

Issue Type Mapping:

  • Bug Reporting → .bug / IssueType.Bug

  • Crash Reporting → .allCrashes / IssueType.AllCrashes

  • Session Replay → .sessionReplay / IssueType.SessionReplay

  • All products → .all / IssueType.All


Optional Step 2 — Add User Identification

Concepts (Platform-Agnostic):

Purpose: Link bug reports to specific user accounts for better tracking

Step 3A: Identify Login Flows

Search Strategy:

  1. Search for authentication/login methods in codebase

  2. Look for successful login callbacks/handlers

  3. Identify where user data becomes available

Placement Rules:

  • Add identification AFTER authentication succeeds

  • Add BEFORE any navigation/routing

  • Ensure user data (email/id/name) is available at this point

API Signature (All Platforms):

Examples by Selection:

  • Option 1 (email): identifyUser(null, user.email, user.name)

  • Option 2 (ID): identifyUser(user.id, null, user.name)

  • Option 3 (both): identifyUser(user.id, user.email, user.name)

Platform-Specific Syntax: See platform guides


Step 3B: Identify Logout Flows

Search Strategy:

  1. Search for logout/signout methods in codebase

  2. Look for session clearing logic

  3. Identify where user data is removed

Placement Rules:

  • Add logout call BEFORE clearing user session/data

  • Ensure it's called on all logout paths

API Signature (All Platforms):

Platform-Specific Syntax: See platform guides


Step 7 — Verification & Testing (Wrap up & validate) [USER-INITIATED ONLY]

⚠️ CRITICAL: This step is ONLY executed when the user explicitly selects "Wrap up & validate" from the optional steps menu. Do NOT run automatically after mandatory steps complete.

After Mandatory Steps Complete

Display this summary and menu:

WAIT for user selection. Do NOT proceed to build verification unless user selects option 2.


1. Build Verification [ONLY WHEN USER REQUESTS]

Execute platform-specific build command:

  • iOS: xcodebuild -project ... -scheme ... build

  • Android: ./gradlew assembleDebug

Expected Result: BUILD SUCCEEDED with no errors

Common Build Errors & Solutions:

Error
Likely Cause
Solution

"no such module" / "unresolved import"

Wrong import statement

Check platform guide for correct import

"version not found"

Invalid SDK version

Verify version fetched from releases

"package not resolved"

Dependency not added

Re-run package manager sync


2. Runtime Testing [MANUAL]

After successful build, instruct user to perform these steps:


3. Final Summary [DISPLAY AFTER BUILD SUCCESS]

Generate and display summary after successful validation:


Error Handling & Troubleshooting

Common Issues Across Platforms:

1. SDK Not Initializing:

  • Verify token is correct

  • Check initialization code placement (usually in app entry point)

  • Ensure import statement is correct

2. Network Logging Not Working:

  • Verify masking code placed AFTER SDK initialization

  • Check that network interceptor is properly configured

  • Ensure app has network permissions

3. User Identification Not Showing:

  • Verify identifyUser called after successful login

  • Check that logout is called on all logout paths

  • Ensure parameters are not all null

4. Reports Not Appearing in Dashboard:

  • Verify device/simulator has internet connection

  • Check app token is correct

  • Wait a few minutes for sync

  • Check dashboard filters


Extension Points for Platform Guides

Platform-specific guides should include:

Required Sections:

  1. Platform-Specific Critical Rules (import naming, package names, etc.)

  2. Pre-Integration Checklist (platform-specific gotchas)

  3. Step 2 Implementation (dependency management code)

  4. Step 3 Implementation (SDK initialization code)

  5. Step 4 Implementation (network logging code) [MANDATORY]

  6. Step 5 Implementation (screenshot masking code) [MANDATORY]

  7. Step 6 Implementation (symbolication upload code) [MANDATORY]

  8. Optional Step 1 Implementation (repro steps mode)

  9. Optional Step 2 Implementation (user identification code)

  10. Step 7 Implementation (build commands, platform-specific testing)

Reference Format:

Luciq SDK Integration - Android Guide

Purpose: Android-specific implementation details for Luciq SDK integration. This guide provides Android-specific code, configuration, and platform requirements.


⚠️ ANDROID-SPECIFIC CRITICAL RULES ⚠️

Package and Import:

  1. Gradle Dependency: implementation 'ai.luciq.library:luciq:<VERSION>'

  2. Import Statement: import ai.luciq.library.Luciq

  3. Language: Code examples in Kotlin (Java equivalents straightforward)

  4. Minimum Requirements: compileSdkVersion 29 or above

  5. Android 15+ (API 35): Requires Luciq 13.4.0+ for 16KB page size support

Android-Specific Execution Rules:

  • Initialize in Application class (not Activity)

  • Network interception: MANDATORY - Configure in Step 3B (Gradle plugin auto-instruments OkHttp/UrlConnection)

  • APM provides: App launch, network performance, UI hangs, screen loading metrics

  • At least email OR id required for user identification (both null = error)

  • Use exact version in gradle (not + or ranges)

  • ALL API parameters must be included (can be null)

Official Android Documentation:

  • Android Integration: https://docs.luciq.ai/docs/android-integration

  • APM Migration: https://docs.luciq.ai/docs/android-luciq-migration

  • User Identification: https://docs.luciq.ai/docs/android-identify-user

  • Network Logging: https://docs.luciq.ai/reference/network-logging-android

  • Screenshot Masking: https://docs.luciq.ai/docs/android-repro-steps

  • Unified Network Interceptor: https://docs.luciq.ai/docs/android-unified-network-interception



ANDROID-SPECIFIC IMPLEMENTATION DETAILS


Pre-Integration Checklist

Before starting, verify you understand these Android-specific points:


Step 1 — Collect Required Information [MANDATORY]

📋 Workflow: See common-workflow.md - Step 1arrow-up-right

Android-Specific Implementation

Package Manager Detection:

Check for:

  • build.gradle / build.gradle.kts → Gradle

  • pom.xml → Maven

Integration Method Menu (if multiple/none detected):

  1. Gradle (Recommended)

  2. Maven


1C: Apply Default Configuration (Inform + Opt-in)

📋 Workflow: See common-workflow.md - Step 1Carrow-up-right

For Android:

  • Default configuration is applied automatically (shake + floatingButton, APM enabled, network masking, etc.)

  • User is informed of defaults and can opt-in to customize

  • If user customizes: Use the customization loop (select → apply → redisplay → confirm)

  • apm_enabled is set to true by default

  • After configuration: Continue to Step 1D


1D: APM (Application Performance Monitoring)

Check Configuration Mode:


Step 2 — Add the Luciq SDK Dependency [MANDATORY]

📋 Workflow: See common-workflow.md - Step 2arrow-up-right Fetch latest version from GitHub API: https://api.github.com/repos/luciqai/luciq-android-sdk/releases/latest Extract version from the "tag_name" field. DO NOT hardcode versions like "18.0.0".

Android Implementation

Check Configuration Mode:

Part A: Gradle Plugins

If integration_method == gradle:

⚠️ Firebase Plugin Order: If project uses Firebase Performance Monitoring, ensure Luciq plugins are declared BEFORE Firebase:

Part B: Add Dependencies

Base Dependencies (Always Required):

APM Dependencies (If config_mode == default OR apm_enabled == true):

Maven (If integration_method == maven):

Automatic Permissions: SDK adds these to AndroidManifest.xml automatically:


Step 3 — Initialize the SDK [MANDATORY]

📋 Workflow: See common-workflow.md - Step 3arrow-up-right

Android Implementation

⚠️ IMPORTANT: The SDK initialization MUST be the FIRST code executed in onCreate() (immediately after super.onCreate()). This ensures Luciq captures all app activity from the very start.

Part A: Detect or Create Application Class

Search for Existing Application Class:

Part B: Initialize Luciq SDK

If NO existing Application class - Create new:

Then register in AndroidManifest.xml:

If existing Application class - Update onCreate():

Part C: APM Configuration (If config_mode == default OR apm_enabled == true)

If APM is enabled, configure APM plugin in build.gradle:

⚠️ IMPORTANT: The APM plugin's networkEnabled captures network data for APM performance monitoring only. You MUST still add the OkHttp interceptor manually (see Optional Step 1) for network logs to appear in bug reports.

Note: Network logging is handled automatically by the unified network interception. Enable it in the luciq block with networkInterception { enabled = true }.

Invocation Events Syntax:

Default invocation events: SHAKE, FLOATING_BUTTON

Available Events:

  • LuciqInvocationEvent.SHAKE - Device shake

  • LuciqInvocationEvent.SCREENSHOT - Screenshot capture

  • LuciqInvocationEvent.FLOATING_BUTTON - Floating button overlay

  • LuciqInvocationEvent.NONE - Manual only


Step 3B — Configure Network Interception [MANDATORY]

Android Implementation (Unified Network Interception)

Minimum SDK Version: 19.0.0+

The Luciq Gradle Plugin automatically instruments OkHttp and UrlConnection networking libraries. No manual interceptor setup required!


Configuration Settings

Setting
Default
Description

networkInterception.enabled

false

Master switch for interception

okHttp.enabled

true

OkHttp automatic integration

urlConnection.enabled

true

UrlConnection automatic integration

okHttp.legacyApmInterceptionEnabled

true

APM legacy interceptor fallback

urlConnection.legacyInterceptionEnabled

true

Core legacy interceptor fallback


Part A: Enable Network Interception (Gradle Plugin)

Kotlin DSL (build.gradle.kts):

Groovy (build.gradle):

Note: Legacy interceptors will be removed in a future major release. Disabling them now ensures smooth future upgrades.


Part B: Selective Library Instrumentation (Optional)

If you need to disable instrumentation for specific libraries:


Part C: Mask Sensitive Data

Use the centralized Luciq.setNetworkLogListener for all captured logs:

Key Points:

  • Headers: Mask with "*****" (preserves header presence for debugging)

  • Body fields: Recursive masking at any depth using Set for O(1) lookup

  • Return null to exclude log entirely


Step 4 — Mask Repro Step Screenshots [MANDATORY]

📋 Workflow: See common-workflow.md - Optional Step 1arrow-up-right

Android Implementation

Minimum SDK Version: 11.13.0

Check Configuration Mode:

Build-time Configuration (Alternative):

Additional Privacy Controls:

Available Masking Types:

  • MaskingType.TEXT_INPUTS - EditText, TextInputLayout, text input fields

  • MaskingType.LABELS - TextView, Button text, labels, titles

  • MaskingType.MEDIA - ImageView, VideoView, images and video

  • MaskingType.MASK_NOTHING - Disable all auto masking

Key Notes:

  • Private Views API takes precedence over Auto Masking

  • Works with Bug Reporting, Crash Reporting, and Session Replay

  • Screenshots are disabled by default for Crash Reporting


Step 5 — Upload Mapping Files [MANDATORY]

📋 Workflow: See common-workflow.md - Step 6arrow-up-right

Android Implementation

This step is required for readable crash reports.

Purpose: Upload ProGuard/R8 mapping files for crash symbolication.

Part A: Create Upload Script

Create upload_mapping.sh in your project root:

Part B: Add Gradle Task

Add to your app's build.gradle or build.gradle.kts:

Kotlin DSL (build.gradle.kts):

Groovy (build.gradle):

Part C: Run After Release Build

Alternative: Manual Dashboard Upload

  1. Navigate to Upload Mapping Files in your Luciq dashboard Settings

  2. Upload your mapping.txt file (found in app/build/outputs/mapping/release/)

  3. Upload for each release version


🛑 MANDATORY STEPS COMPLETE


Optional Step 1 — Configure Repro Steps Mode

📋 Workflow: See common-workflow.md - Optional Step 1arrow-up-right

Android Implementation

Based on user selections, apply configuration:

Issue Type Options:

  • IssueType.Bug - Bug Reporting

  • IssueType.AllCrashes - Crash Reporting

  • IssueType.SessionReplay - Session Replay

  • IssueType.All - All products

Key Points:

  • Selected products → ReproMode.EnableWithScreenshots

  • Non-selected products → ReproMode.EnableWithNoScreenshots


Optional Step 2 — Add User Identification

📋 Workflow: See common-workflow.md - Optional Step 2arrow-up-right

Android Implementation - Login Flow

API Signature:

⚠️ CRITICAL: At least email OR id must be non-null. All null throws error.

Examples:

  • Email only: Luciq.identifyUser(user.name, user.email, null)

  • ID only: Luciq.identifyUser(user.name, null, user.id)

  • Both: Luciq.identifyUser(user.name, user.email, user.id)

Additional User Data (optional):

Android Implementation - Logout Flow

Note: logoutUser() only works if user was previously identified


Step 6 — Verification & Testing [WRAP UP & VALIDATE]

📋 Workflow: See common-workflow.md - Step 7arrow-up-right

Android Build Verification

Expected: BUILD SUCCESSFUL

Android-Specific Build Errors:

Error
Cause
Fix

compileSdkVersion < 29

SDK too old

Set compileSdkVersion to 29+

Unresolved reference: Luciq

Missing dependency

Sync gradle, verify version

Duplicate class

Dependency conflict

Check: ./gradlew dependencies

Android Runtime Testing

  1. Install and run:

  2. Trigger Luciq:

    • Shake: Shake device/emulator

    • Screenshot: Power + Volume Down

    • Floating Button: Tap button overlay

  3. Verify Luciq UI appears

  4. Submit test report

  5. Check dashboard: https://dashboard.luciq.ai


Android-Specific Troubleshooting

Issue: "compileSdkVersion must be >= 29"

Fix: Update build.gradle:

Issue: Network logs not appearing

Fix: Enable unified network interception in luciq { networkInterception { enabled = true } }

Issue: Application class not registered

Fix: Add android:name=".MyApplication" to <application> tag in manifest

Issue: User identification error

Fix: Ensure at least email OR id is non-null (not both null)

Issue: Screenshots not masking

Fix: Use setAutoMaskScreenshotsTypes(MaskingType.TEXT_INPUTS, MaskingType.LABELS)


Quick Reference


Java Equivalents

All Kotlin examples have straightforward Java equivalents:

  • valfinal

  • Lambda { } → Anonymous inner class

  • ?.let → null check with if

  • Extension functions → Static utility methods

Refer to official docs for Java examples if needed.

Last updated