Skill for diagnosing and fixing the binary compatibility check (apiCheck)
Purpose
./gradlew apiCheck fails, check the API changes and fix them.
Diagnosing the problem
Step 1: Checking the error
Command to run:
./gradlew apiCheck --info
Information to grasp from the error message:
- What API was changed (class, function, property)
- Whether the change is unexpected or intentional
- Which modules are affected
Example error message:
Expected file with API declarations 'extension/navigation3/api/android/extension-navigation3.api' does not exist.
Fix procedure
Pattern A: The API file does not exist
Cause: A new module was added, or the API file has not been committed.
How to fix:
- Generate the API file:
./gradlew :module:apiDumpRun - Check the file:
api/Confirm that the API file was generated in the directory - If the module is empty: Comment out the module itself, or add a placeholder
./gradlew :extension:extension-navigation:apiDump
./gradlew :extension:extension-navigation3:apiDump
Pattern B: The API was changed intentionally
Check procedure:
- Check the changed API
- Read the source code with Read
- Determine whether the change is intentional
How to fix (for intentional changes):
api/Update the files in the directory- Confirm that the changes are reflected in the API file
Pattern C: The API was changed unintentionally
How to fix:
- Check the source code with Read
- Revert the changes with Edit
- Run
./gradlew apiCheckagain
Verification
After fixing, verify with the following command:
./gradlew apiCheck
Confirm that the binary compatibility check succeeds (exit code 0).
Reference information
- The API check is a feature for guaranteeing binary compatibility in Kotlin Multiplatform
api/The directory stores the API declarations for each platform (Android, JVM, Native, etc.)- It is recommended not to edit API files manually, but to generate them automatically with the
apiDumptask