Development Setup¶
This guide covers setting up the development environment for the Cryptographer project.
Prerequisites¶
- Android Studio: Hedgehog (2023.1.1) or later
- JDK: Version 17 or later
- Git: For version control
- Android SDK: API 33+ installed
Initial Setup¶
1. Clone Repository¶
2. Open in Android Studio¶
- Launch Android Studio
- File → Open
- Select the
cryptographerdirectory - Click OK
3. Sync Gradle¶
Android Studio will automatically sync Gradle. If not:
- File → Sync Project with Gradle Files
- Wait for sync to complete
4. Install Git Hooks (Optional)¶
This installs pre-commit hooks that run: - Spotless formatting check - Detekt static analysis
Project Structure¶
cryptographer/
├── app/ # Application module
│ ├── src/
│ │ ├── main/ # Main source code
│ │ ├── test/ # Unit tests
│ │ └── androidTest/ # Instrumented tests
│ └── build.gradle.kts # App build configuration
├── gradle/ # Gradle configuration
│ └── libs.versions.toml # Version catalog
├── docs/ # Documentation
├── build.gradle.kts # Project build configuration
├── gradle.properties # Gradle properties
└── mkdocs.yml # Documentation configuration
Development Workflow¶
1. Create Feature Branch¶
2. Make Changes¶
- Write code following Clean Architecture principles
- Add tests for new functionality
- Ensure code passes quality checks
3. Run Quality Checks¶
# Format code
./gradlew spotlessApply
# Check formatting
./gradlew spotlessCheck
# Run static analysis
./gradlew detekt
# Run tests
./gradlew test
4. Commit Changes¶
Pre-commit hooks will run automatically if installed.
5. Push and Create Merge Request¶
Create a merge request in GitLab.
Code Style¶
Kotlin Style Guide¶
Follow Kotlin Coding Conventions.
Formatting¶
Code is automatically formatted using Spotless (ktlint):
Naming Conventions¶
- Classes: PascalCase (
KeyGenerationViewModel) - Functions: camelCase (
generateKey) - Variables: camelCase (
uiState) - Constants: UPPER_SNAKE_CASE (
MAX_KEY_SIZE) - Packages: lowercase (
com.example.cryptographer)
Testing¶
Unit Tests¶
Test location: app/src/test/
Instrumented Tests¶
Requires connected device or emulator.
Test location: app/src/androidTest/
Debugging¶
Run in Debug Mode¶
- Click Run button (▶️)
- Select Debug configuration
- Set breakpoints as needed
View Logs¶
Use Android Studio’s Logcat to view application logs.
Common Tasks¶
Add New Dependency¶
- Add to
gradle/libs.versions.toml:
- Reference in
app/build.gradle.kts:
implementation(libs.new.library)
- Sync Gradle
Add New Screen¶
- Create screen in
presentation/ - Create ViewModel with
@HiltViewModel - Add navigation route
- Add UI components
Add New Feature¶
- Define domain entities/value objects
- Create domain services
- Add command/query handlers
- Create ViewModel
- Build UI with Compose
Troubleshooting¶
Gradle Sync Fails¶
- Invalidate Caches: File → Invalidate Caches → Invalidate and Restart
- Clean Build: Build → Clean Project
- Check JDK: File → Project Structure → SDK Location
Build Errors¶
- SDK Issues: Install required SDK via SDK Manager
- Dependency Conflicts: Run
./gradlew --refresh-dependencies - Kotlin Version: Check
gradle/libs.versions.toml
Test Failures¶
- Check test output in
app/build/reports/tests/ - Run tests individually to isolate issues
- Check test dependencies
Learn More¶
- Code Quality - Quality tools and checks
- Testing - Testing strategies
- CI/CD - Continuous Integration