Compare commits

...

3 Commits

Author SHA1 Message Date
claude[bot]
3835b051ff Bump implementing-android-code skill version to 0.1.1 2026-02-25 19:44:42 +00:00
Patrick Honkonen
de45264511 Fix implementing-android-code skill annotations and formatting
Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-24 13:04:42 -05:00
Patrick Honkonen
b358d3c070 Extract troubleshooting guide into docs/TROUBLESHOOTING.md
Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-24 12:54:53 -05:00
6 changed files with 76 additions and 77 deletions

View File

@@ -278,57 +278,7 @@ Follow semantic versioning pattern: `YEAR.MONTH.PATCH`
---
## Troubleshooting
## Quick Reference
### Common Issues
#### Build fails with SDK dependency error
**Problem**: Cannot resolve Bitwarden SDK from GitHub Packages
**Solution**:
1. Ensure `GITHUB_TOKEN` is set in `ci.properties` or environment
2. Verify token has `read:packages` scope
3. Check network connectivity to `maven.pkg.github.com`
#### Tests fail with dispatcher issues
**Problem**: Tests hang or fail with "Module with Main dispatcher had failed to initialize"
**Solution**:
1. Extend `BaseViewModelTest` for ViewModel tests
2. Use `@RegisterExtension val mainDispatcherExtension = MainDispatcherExtension()`
3. Ensure `runTest { }` wraps test body
#### Compose preview not rendering
**Problem**: @Preview functions show "Rendering problem"
**Solution**:
1. Check for missing theme wrapper: `BitwardenTheme { YourComposable() }`
2. Verify no ViewModel dependency in preview (use state-based preview)
3. Clean and rebuild project
#### ProGuard/R8 stripping required classes
**Problem**: Release build crashes with missing class errors
**Solution**:
1. Add keep rules to `proguard-rules.pro`
2. Check `consumer-rules.pro` in library modules
3. Verify kotlinx.serialization rules are present
### Debug Tips
- **Timber Logging**: Enabled in debug builds, check Logcat with tag filter
- **Debug Menu**: Available in debug builds via Settings > About > Debug Menu
- **Network Inspector**: Use Android Studio Network Profiler or Charles Proxy
- **SDK Debugging**: Check `BaseSdkSource` for wrapped exceptions
---
## References
- `docs/ARCHITECTURE.md` - Architecture patterns, templates, examples
- `docs/STYLE_AND_BEST_PRACTICES.md` - Code style, formatting, Compose conventions
- [Bitwarden SDK](https://github.com/bitwarden/sdk) | [Jetpack Compose](https://developer.android.com/jetpack/compose) | [Hilt DI](https://dagger.dev/hilt/) | [Turbine](https://github.com/cashapp/turbine) | [MockK](https://mockk.io/)
- **Troubleshooting**: See `docs/TROUBLESHOOTING.md`
- **Architecture**: `docs/ARCHITECTURE.md` | [Bitwarden SDK](https://github.com/bitwarden/sdk) | [Jetpack Compose](https://developer.android.com/jetpack/compose) | [Hilt DI](https://dagger.dev/hilt/)

View File

@@ -5,6 +5,17 @@ All notable changes to the `implementing-android-code` skill will be documented
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.1] - 2026-02-25
### Fixed
- Added missing `@EncryptedPreferences` and `@UnencryptedPreferences` annotations to `ExampleDiskSourceImpl` code example
- Fixed typographic apostrophe example to use correct right single quotation mark (U+2019)
### Removed
- Removed redundant "Summary" section that duplicated existing content
## [0.1.0] - 2026-02-17
### Added
@@ -20,4 +31,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Clock/time injection patterns for deterministic operations
- Anti-patterns and common gotchas
- Copy-pasteable code templates (templates.md) for all layer types
- README.md, CHANGELOG.md, CONTRIBUTING.md for marketplace preparation
- README.md, CHANGELOG.md, CONTRIBUTING.md for marketplace preparation

View File

@@ -41,4 +41,4 @@ All pull requests that modify skill content must include:
1. A version bump in the SKILL.md frontmatter
2. A corresponding CHANGELOG.md entry
3. Verification that templates compile against the current codebase patterns
3. Verification that templates compile against the current codebase patterns

View File

@@ -74,4 +74,4 @@ This skill is part of the [Bitwarden Android](https://github.com/bitwarden/andro
## Support
For issues or questions, open an issue in the [bitwarden/android](https://github.com/bitwarden/android) repository.
For issues or questions, open an issue in the [bitwarden/android](https://github.com/bitwarden/android) repository.

View File

@@ -1,6 +1,6 @@
---
name: implementing-android-code
version: 0.1.0
version: 0.1.1
description: This skill should be used when implementing Android code in Bitwarden. Covers critical patterns, gotchas, and anti-patterns unique to this codebase. Triggered by "How do I implement a ViewModel?", "Create a new screen", "Add navigation", "Write a repository", "BaseViewModel pattern", "State-Action-Event", "type-safe navigation", "@Serializable route", "SavedStateHandle persistence", "process death recovery", "handleAction", "sendAction", "Hilt module", "Repository pattern", "implementing a screen", "adding a data source", "handling navigation", "encrypted storage", "security patterns", "Clock injection", "DataState", or any questions about implementing features, screens, ViewModels, data sources, or navigation in the Bitwarden Android app.
---
@@ -273,7 +273,7 @@ Search `ui/src/main/kotlin/com/bitwarden/ui/platform/components/` for existing `
New strings belong in the `:ui` module: `ui/src/main/res/values/strings.xml`
- Use typographic apostrophes and quotes to avoid escape characters: `you'll` not `you\'ll`, `“word”` not `\"word\"`
- Use typographic apostrophes and quotes to avoid escape characters: `youll` not `you\'ll`, `“word”` not `\"word\"`
- Reference strings via generated `BitwardenString` resource IDs
- Do not add strings to other modules unless explicitly instructed
@@ -288,8 +288,8 @@ New strings belong in the `:ui` module: `ui/src/main/res/values/strings.xml`
**Pattern Summary:**
```kotlin
class ExampleDiskSourceImpl(
encryptedSharedPreferences: SharedPreferences,
sharedPreferences: SharedPreferences,
@EncryptedPreferences encryptedSharedPreferences: SharedPreferences,
@UnencryptedPreferences sharedPreferences: SharedPreferences,
) : BaseEncryptedDiskSource(
encryptedSharedPreferences = encryptedSharedPreferences,
sharedPreferences = sharedPreferences,
@@ -478,20 +478,3 @@ When pointing to specific code, use: `file_path:line_number`
Example: `ui/src/main/kotlin/com/bitwarden/ui/platform/base/BaseViewModel.kt` (see `handleAction` method)
---
## Summary
This skill captures **Bitwarden-specific patterns** that distinguish this codebase:
1. **State-Action-Event ViewModel pattern** - Synchronous state updates via `handleAction()`
2. **Type-safe navigation** - No strings, `@Serializable` routes
3. **No-throw error handling** - `Result<T>` and sealed classes
4. **Interface/Impl separation** - Testability and DI safety
5. **SavedStateHandle persistence** - Process death recovery
6. **Security patterns** - Encrypted storage, Keystore, input validation
7. **Clock injection** - Deterministic time handling via injected `Clock`
For comprehensive details on architecture, module organization, and complete code style rules, always consult:
- `docs/ARCHITECTURE.md`
- `docs/STYLE_AND_BEST_PRACTICES.md`

55
docs/TROUBLESHOOTING.md Normal file
View File

@@ -0,0 +1,55 @@
# Troubleshooting
## Common Issues
### Build fails with SDK dependency error
**Problem**: Cannot resolve Bitwarden SDK from GitHub Packages
**Solution**:
1. Ensure `GITHUB_TOKEN` is set in `ci.properties` or environment
2. Verify token has `read:packages` scope
3. Check network connectivity to `maven.pkg.github.com`
### Tests fail with dispatcher issues
**Problem**: Tests hang or fail with "Module with Main dispatcher had failed to initialize"
**Solution**:
1. Extend `BaseViewModelTest` for ViewModel tests
2. Use `@RegisterExtension val mainDispatcherExtension = MainDispatcherExtension()`
3. Ensure `runTest { }` wraps test body
### Compose preview not rendering
**Problem**: @Preview functions show "Rendering problem"
**Solution**:
1. Check for missing theme wrapper: `BitwardenTheme { YourComposable() }`
2. Verify no ViewModel dependency in preview (use state-based preview)
3. Clean and rebuild project
### ProGuard/R8 stripping required classes
**Problem**: Release build crashes with missing class errors
**Solution**:
1. Add keep rules to `proguard-rules.pro`
2. Check `consumer-rules.pro` in library modules
3. Verify kotlinx.serialization rules are present
### App module test flavor errors
**Problem**: `./gradlew app:testDebugUnitTest` fails or runs no tests
**Solution**: The app module uses build flavors. Use `testStandardDebugUnitTest`:
```bash
./gradlew app:testStandardDebugUnitTest
```
## Debug Tips
- **Timber Logging**: Enabled in debug builds, check Logcat with tag filter
- **Debug Menu**: Available in debug builds via Settings > About > Debug Menu
- **Network Inspector**: Use Android Studio Network Profiler or Charles Proxy
- **SDK Debugging**: Check `BaseSdkSource` for wrapped exceptions