Troubleshooting¶
Common issues and solutions for single-module and multi-module setups.
General Issues¶
Generated Fakes Not Appearing¶
Symptoms: IDE doesn’t recognize fakeXxx() factory functions
Solutions:
- Rebuild the project:
./gradlew clean build - Invalidate IDE caches: File → Invalidate Caches → Invalidate and Restart
- Check build directory: Fakes are in
build/generated/fakt/commonTest/kotlin/ - Verify Gradle sync: Ensure Gradle sync completed successfully
Unresolved Reference: fakeXxx¶
Common causes:
- Missing build step: Run
./gradlew buildfirst - Wrong source set: Import from test code (
src/commonTest/), not main - Package mismatch: Generated fakes are in the same package as the interface
- Gradle sync issue: Re-sync Gradle in your IDE
Compilation Fails with “IrTypeAliasSymbol not found”¶
Causes:
- Kotlin version mismatch: Ensure you’re on Kotlin 2.2.21+
- Fakt version incompatibility: Update Fakt to match your Kotlin version
Solution:
Build is Slow¶
Solutions:
-
Use LogLevel.QUIET in CI/CD:
-
Check cache hit rate with
LogLevel.INFO -
Verify incremental compilation is enabled
Multi-Module Issues¶
Diagnosis Tools¶
Enable Debug Logging:
Rebuild to see detailed output:
Check Task Execution:
# View task dependency graph
./gradlew :core:analytics-fakes:build --dry-run
# Use build scans
./gradlew build --scan
Issue 1: “No fakes found in source module”¶
Error:
No fakes found in source module 'analytics'.
Verify that source module has @Fake annotated interfaces.
Causes:
1. Source module has no @Fake interfaces
2. Fakes not generated (compilation failed)
3. Wrong module path in collectFakesFrom()
Diagnosis:
# Check for @Fake annotations
grep -r "@Fake" core/analytics/src/
# Verify fakes were generated
ls core/analytics/build/generated/fakt/
# Check for compilation errors
./gradlew :core:analytics:build
Solutions:
// ✅ CORRECT: Collect from producer (has @Fake interfaces)
fakt {
@OptIn(com.rsicarelli.fakt.compiler.api.ExperimentalFaktMultiModule::class)
collectFakesFrom(projects.core.analytics)
}
// ❌ WRONG: Collecting from collector (no @Fake interfaces)
fakt {
@OptIn(com.rsicarelli.fakt.compiler.api.ExperimentalFaktMultiModule::class)
collectFakesFrom(projects.core.analyticsFakes) // Wrong!
}
Issue 2: “Unresolved reference: fakeXxx” (Multi-Module)¶
Error:
Causes:
1. Consumer doesn’t depend on collector module
2. Collector module not built
3. IDE not synced
4. Wrong import
Diagnosis:
# Check dependency in consumer
grep "analyticsFakes" app/build.gradle.kts
# Verify collector was built
ls core/analytics-fakes/build/generated/collected-fakes/
# Check for factory function
grep -r "fun fakeAnalytics" core/analytics-fakes/build/
Solutions:
// 1. Add dependency to consumer
kotlin {
sourceSets.commonTest.dependencies {
implementation(projects.core.analyticsFakes)
}
}
// 2. Sync Gradle and rebuild
./gradlew --refresh-dependencies build
// 3. Invalidate IDE caches
// File → Invalidate Caches → Invalidate and Restart
Issue 3: Targets Mismatch¶
Error:
Cause: Collector has different targets than producer
Diagnosis:
// Check producer targets
// core/analytics/build.gradle.kts
kotlin {
jvm()
iosArm64() // ← Producer has this
}
// Check collector targets
// core/analytics-fakes/build.gradle.kts
kotlin {
jvm()
// Missing: iosArm64() ← Collector doesn't!
}
Solution: Collector MUST have ALL producer’s targets
// core/analytics-fakes/build.gradle.kts
kotlin {
jvm()
iosArm64() // ✅ Added
iosX64()
iosSimulatorArm64()
}
Issue 4: Wrong Platform Placement¶
Symptom: Fake ends up in wrong source set (e.g., commonMain instead of jvmMain)
Cause: Package doesn’t contain platform identifier
Diagnosis:
// Check generated fake's package
// core/analytics/build/generated/fakt/jvmTest/kotlin/DatabaseFake.kt
package com.example.database // ← No "jvm" segment!
Solution: Use platform identifier in package name
// ✅ CORRECT: Platform in package
package com.example.jvm.database // → jvmMain/
package com.example.ios.camera // → iosMain/
// ❌ WRONG: No platform identifier
package com.example.database // → commonMain/ (fallback)
Issue 5: Circular Dependencies¶
Error:
Cause: Feature A fakes need Feature B, Feature B fakes need Feature A
Solution: Extract shared interfaces to core modules
Before (circular):
features/payment → features/user
features/user → features/payment
After (fixed):
core/payment-api @Fake interface PaymentProvider
core/user-api @Fake interface UserProvider
features/payment → core/payment-api, core/user-api
features/user → core/user-api, core/payment-api
Issue 6: Missing Transitive Dependencies¶
Error:
// In test
val fake = fakeAnalytics { } // Compiles
// But runtime error:
NoClassDefFoundError: kotlinx/coroutines/CoroutineScope
Cause: Collector didn’t declare coroutines dependency
Solution:
// core/analytics-fakes/build.gradle.kts
kotlin {
sourceSets.commonMain.dependencies {
api(projects.core.analytics)
implementation(libs.coroutines) // ✅ Add this
}
}
How to identify needed dependencies:
# Inspect generated code
cat core/analytics-fakes/build/generated/collected-fakes/commonMain/kotlin/FakeAnalyticsImpl.kt
# Look for imports:
import kotlinx.coroutines.* # → Need coroutines
import kotlinx.serialization.* # → Need serialization
Issue 7: IDE Not Finding Fakes¶
Symptom: Autocomplete doesn’t suggest fakeXxx(), but code compiles
Causes:
1. IDE not synced with Gradle
2. Generated sources not indexed
3. Stale IDE caches
Solutions:
# 1. Reload Gradle projects
# File → Reload All Gradle Projects
# 2. Invalidate caches
# File → Invalidate Caches → Invalidate and Restart
# 3. Rebuild project
./gradlew clean build
# 4. Check generated sources are registered
ls core/analytics-fakes/build/generated/collected-fakes/
Issue 8: Configuration Cache Failures¶
Error:
Cause: Using configuration cache with older Fakt version
Solution: Update to the latest Fakt version (configuration cache compatible)
Error Messages Reference¶
“Source project not found”¶
Source project ':core:analytics' not found.
Verify module exists and is included in settings.gradle.kts.
Fix: Add module to settings.gradle.kts
“Collector and producer targets mismatch”¶
Collector has targets [jvm, js] but producer has [jvm, ios].
All producer targets must be present in collector.
Fix: Add missing targets to collector
“@OptIn annotation missing”¶
Fix: Add opt-in annotation
fakt {
@OptIn(com.rsicarelli.fakt.compiler.api.ExperimentalFaktMultiModule::class)
collectFakesFrom(projects.core.analytics)
}
Advanced Debugging¶
Enable TRACE Logging¶
Shows:
- File-by-file collection
- Platform detection reasoning
- IR generation details
- Task execution timing
Task Dependency Visualization¶
# Show task graph
./gradlew :app:test --dry-run
# Execution timeline
./gradlew :app:test --scan
# → View timeline in build scan
Inspect Generated Code¶
# View collected fake
cat core/analytics-fakes/build/generated/collected-fakes/commonMain/kotlin/com/example/FakeAnalyticsImpl.kt
# Compare with original
cat core/analytics/build/generated/fakt/commonTest/kotlin/com/example/FakeAnalyticsImpl.kt
Verification Checklist¶
Before reporting issues, verify:
Single-Module:
- [ ] Interface has @Fake annotation
- [ ] Project builds successfully (./gradlew build)
- [ ] Fakes generated (ls build/generated/fakt/)
- [ ] Gradle synced in IDE
- [ ] Using Kotlin 2.2.21+
Multi-Module:
- [ ] Producer module has @Fake annotated interfaces
- [ ] Producer builds successfully (./gradlew :core:analytics:build)
- [ ] Fakes generated in producer (ls core/analytics/build/generated/fakt/)
- [ ] Collector depends on producer with correct path
- [ ] Collector has ALL producer’s KMP targets
- [ ] Collector declares transitive dependencies
- [ ] Consumer depends on collector module
- [ ] Gradle synced in IDE
- [ ] Using latest Fakt version
- [ ] Kotlin 2.2.21+
Getting Help¶
Before Reporting Issues¶
Please verify these steps before creating a bug report:
- Check existing issues: Search open issues for duplicates
- Enable DEBUG logging: Set
logLevel.set(LogLevel.DEBUG)in yourfakt {}block - Collect diagnostic info: Fakt version, Kotlin version, project type
- Create minimal reproduction: Simplest code that shows the problem
- Gather build logs: Run
./gradlew build --info
Use our Bug Report template - it asks for exactly this information!
For KMP projects, also include your Gradle version and target platforms.
See Also¶
- FAQ - Frequently asked questions
- Multi-Module - Multi-module architecture and setup guide
- Configuration - Plugin options (coming soon)