Skip to content

Migrate to Android Gradle Plugin 9 and upgrade packages#60

Merged
ricky9667 merged 10 commits intomasterfrom
chore/migrate-to-agp-9
Feb 24, 2026
Merged

Migrate to Android Gradle Plugin 9 and upgrade packages#60
ricky9667 merged 10 commits intomasterfrom
chore/migrate-to-agp-9

Conversation

@ricky9667
Copy link
Owner

Summary

This pull request migrates the project's dependency injection framework from Hilt to Koin, updates several dependencies and Gradle configuration, and replaces Material Icons with custom vector drawables. The most significant changes are the removal of Hilt, introduction of Koin for dependency injection, code and configuration updates to support this migration, and minor UI improvements.

Dependency Injection Migration:

  • Replaced Hilt with Koin throughout the project:

ViewModel and Repository Refactoring:

  • Updated all ViewModel and repository classes to remove Hilt annotations and constructor injection, switching to Koin's injection pattern [1] [2] [3] [4].
  • Added a custom KeyboardViewModelFactory for cases where ViewModelProvider is used directly [1] [2] [3].

UI and Resource Updates:

  • Replaced usage of Material Icons (from Icons.Default) with custom vector drawable resources for check and info icons, and updated relevant Compose UI code to use painterResource [1] [2] [3] [4] [5] [6] [7].

Gradle and Dependency Updates:

  • Updated several library versions and Gradle plugins, including Compose, Kotlin, AndroidX, and others.
  • Changed Java and Kotlin compile targets from version 21 to 17 for broader compatibility [1] [2].

Build Configuration Improvements:

  • Added and updated build properties in gradle.properties for improved build behavior and compatibility.

These changes collectively modernize the project, simplify dependency management, and improve maintainability by adopting Koin and updating dependencies.

@ricky9667 ricky9667 self-assigned this Feb 24, 2026
@ricky9667 ricky9667 added the enhancement Developer enhancements or upgrades label Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request performs a major architectural migration from Hilt to Koin for dependency injection, alongside updating the project to Gradle 9 and Android Gradle Plugin 9.0.1. The PR also downgrades Java/Kotlin target from version 21 to 17, updates numerous dependencies, replaces Material Icons with custom vector drawables, and adds multiple Gradle configuration properties.

Changes:

  • Complete migration from Hilt to Koin dependency injection framework with corresponding updates to all ViewModels, repositories, and the Application class
  • Major version updates: Gradle 8.14.3 → 9.3.1, Android Gradle Plugin 8.11.1 → 9.0.1, Kotlin 2.2.0 → 2.3.10, and multiple AndroidX libraries
  • Java/Kotlin compile target downgraded from version 21 to 17 for broader compatibility
  • Replaced Material Icons with custom vector drawable resources for check and info icons
  • Added 10 new Gradle configuration properties to gradle.properties

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
gradle/wrapper/gradle-wrapper.properties Updates Gradle wrapper from 8.14.3 to 9.3.1
gradle/libs.versions.toml Updates multiple dependency versions and replaces Hilt dependencies with Koin
gradle.properties Adds 10 new Gradle configuration properties for build behavior
build.gradle.kts Removes Hilt plugin from root build file
app/build.gradle.kts Removes Hilt dependencies and kapt plugin, adds Koin dependencies, downgrades Java/Kotlin to version 17
app/src/main/res/drawable/ic_info.xml Adds new custom info icon vector drawable
app/src/main/res/drawable/ic_check.xml Adds new custom check icon vector drawable
app/src/main/java/com/rickyhu/hushkeyboard/settings/ui/AppVersionItem.kt Replaces Material Icons with custom drawable resource
app/src/main/java/com/rickyhu/hushkeyboard/settings/SettingsViewModel.kt Removes Hilt annotations, updates to Koin constructor injection
app/src/main/java/com/rickyhu/hushkeyboard/settings/SettingsScreen.kt Replaces hiltViewModel() with koinViewModel()
app/src/main/java/com/rickyhu/hushkeyboard/service/HushIMEService.kt Removes Hilt, adds manual ViewModel instantiation with custom factory and Koin repository injection
app/src/main/java/com/rickyhu/hushkeyboard/main/MainViewModel.kt Removes Hilt annotations, updates to standard constructor
app/src/main/java/com/rickyhu/hushkeyboard/main/MainApp.kt Replaces hiltViewModel() with koinViewModel()
app/src/main/java/com/rickyhu/hushkeyboard/keyboard/KeyboardViewModelFactory.kt Adds new custom ViewModelFactory for manual ViewModel creation in IME service
app/src/main/java/com/rickyhu/hushkeyboard/keyboard/KeyboardViewModel.kt Removes Hilt annotations, updates to standard constructor
app/src/main/java/com/rickyhu/hushkeyboard/introduction/Step3Section.kt Replaces Material Icons with custom drawable resource
app/src/main/java/com/rickyhu/hushkeyboard/di/AppModule.kt Creates new Koin module defining all dependency injection bindings
app/src/main/java/com/rickyhu/hushkeyboard/data/SettingsRepository.kt Removes Hilt annotations, updates to standard constructor
app/src/main/java/com/rickyhu/hushkeyboard/MainActivity.kt Removes Hilt @AndroidEntryPoint annotation
app/src/main/java/com/rickyhu/hushkeyboard/HushApplication.kt Removes Hilt, adds Koin initialization with module setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML formatting is inconsistent. The vector tag has all attributes on a single line making it difficult to read, while ic_info.xml has properly formatted attributes on separate lines. For consistency and maintainability, please format the attributes on separate lines as done in ic_info.xml.

Suggested change
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:tint="#000000"
android:viewportHeight="960"
android:viewportWidth="960"
android:width="24dp">

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +48
viewModel =
ViewModelProvider(
owner = this,
factory = KeyboardViewModelFactory(settingsRepository),
)[KeyboardViewModel::class.java]
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyboardViewModel is registered in the Koin module (AppModule.kt line 16) but is also being instantiated manually using a custom ViewModelFactory in HushIMEService. This creates two different instantiation paths for the same ViewModel, which could lead to confusion and maintenance issues. Consider whether the Koin registration is actually used anywhere, or if the manual factory approach is necessary due to IME service lifecycle constraints. If the Koin registration is not used, it should be removed to avoid confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +19
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Java version has been downgraded from 21 to 17. While this increases compatibility, please ensure this change is intentional and necessary. Java 21 is the latest LTS version and offers significant performance and feature improvements. If the downgrade is required for specific compatibility reasons, those reasons should be documented in the PR description or commit message.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +32
android.nonTransitiveRClass=true
android.defaults.buildfeatures.resvalues=true
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
android.enableAppCompileTimeRClass=false
android.usesSdkInManifest.disallowed=false
android.uniquePackageNames=false
android.dependency.useConstraints=true
android.r8.strictFullModeForKeepRules=false
android.r8.optimizedResourceShrinking=false
android.builtInKotlin=false
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple new Gradle properties have been added without documentation or explanation. Some of these properties (like android.newDsl=false, android.builtInKotlin=false) explicitly disable new features, which may impact future compatibility and migration paths. Consider adding comments explaining why each property is set to its specific value, especially for properties that disable newer features.

Suggested change
android.nonTransitiveRClass=true
android.defaults.buildfeatures.resvalues=true
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
android.enableAppCompileTimeRClass=false
android.usesSdkInManifest.disallowed=false
android.uniquePackageNames=false
android.dependency.useConstraints=true
android.r8.strictFullModeForKeepRules=false
android.r8.optimizedResourceShrinking=false
android.builtInKotlin=false
android.nonTransitiveRClass=true
# Explicitly enable generation of resValues via the buildFeatures DSL to keep legacy
# resource value handling behavior stable across Android Gradle Plugin upgrades.
android.defaults.buildfeatures.resvalues=true
# Do not automatically default targetSdkVersion to compileSdkVersion to ensure the
# app's targetSdkVersion remains explicitly controlled in the Gradle configuration.
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
# Keep the R class generated at build time to avoid changing resource access patterns
# in existing code and to reduce risk during migration to newer AGP versions.
android.enableAppCompileTimeRClass=false
# Allow uses-sdk to be declared in the AndroidManifest for backward compatibility
# with existing manifests that rely on this behavior.
android.usesSdkInManifest.disallowed=false
# Do not enforce unique applicationId/packageName across all modules to maintain
# compatibility with current module and package naming schemes.
android.uniquePackageNames=false
# Use dependency constraints to ensure consistent versions across modules and avoid
# accidental dependency version drift in the project.
android.dependency.useConstraints=true
# Do not enable strict R8 full mode for keep rules to avoid potentially aggressive
# shrinking and obfuscation changes that could break existing code paths.
android.r8.strictFullModeForKeepRules=false
# Keep R8 optimized resource shrinking disabled to preserve current resource packaging
# behavior and reduce the risk of inadvertently removing required resources.
android.r8.optimizedResourceShrinking=false
# Disable the built-in Kotlin integration in AGP; Kotlin configuration is managed
# explicitly via the Kotlin Gradle plugin to keep build configuration centralized.
android.builtInKotlin=false
# Disable the new Gradle Android DSL to avoid unexpected breaking changes in the
# build scripts and to allow a controlled, explicit migration when ready.

Copilot uses AI. Check for mistakes.
@ricky9667 ricky9667 changed the title Migrate to Android Gradle Plugin 9 Migrate to Android Gradle Plugin 9 and upgrade packages Feb 24, 2026
@ricky9667 ricky9667 merged commit 3b11e1a into master Feb 24, 2026
1 check passed
@ricky9667 ricky9667 deleted the chore/migrate-to-agp-9 branch February 24, 2026 03:18
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 17.33333% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.89%. Comparing base (f53588f) to head (7dfb902).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...rickyhu/hushkeyboard/settings/SettingsViewModel.kt 0.00% 19 Missing ⚠️
...main/java/com/rickyhu/hushkeyboard/main/MainApp.kt 0.00% 15 Missing ⚠️
...om/rickyhu/hushkeyboard/data/SettingsRepository.kt 0.00% 8 Missing ⚠️
...rickyhu/hushkeyboard/keyboard/KeyboardViewModel.kt 0.00% 8 Missing ⚠️
...ava/com/rickyhu/hushkeyboard/main/MainViewModel.kt 0.00% 6 Missing ⚠️
...c/main/java/com/rickyhu/hushkeyboard/main/Route.kt 0.00% 3 Missing ⚠️
.../rickyhu/hushkeyboard/introduction/Step3Section.kt 0.00% 1 Missing ⚠️
...com/rickyhu/hushkeyboard/service/HushIMEService.kt 0.00% 1 Missing ⚠️
...om/rickyhu/hushkeyboard/settings/SettingsScreen.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
+ Coverage   53.15%   53.89%   +0.74%     
==========================================
  Files          39       40       +1     
  Lines         999      950      -49     
  Branches       84       85       +1     
==========================================
- Hits          531      512      -19     
+ Misses        432      402      -30     
  Partials       36       36              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Developer enhancements or upgrades

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants