Update minimum SDK to API 26 (Android 8.0 Oreo)#2806
Merged
pyricau merged 4 commits intosquare:mainfrom Mar 5, 2026
Merged
Conversation
This commit migrates the entire LeakCanary project from minimum SDK API 14 to API 21, enabling modern Android features and simplifying the codebase. API 21 corresponds to Android 5.0 (Lollipop), released in 2014, providing over a decade of Android compatibility while enabling Material Design and modern development practices. Changes included: ## Build Configuration - Update androidMinSdk from "14" to "21" in version catalog - Standardize all modules to use libs.versions.androidMinSdk reference - Update hardcoded minSdk values in sample and library modules to use TOML ## GitHub Actions / CI - Remove API 16 and API 19 from test matrix - Streamline CI to test only API 21+ (21, 23, 26, 31, 33, 34) - Improve CI efficiency with fewer test combinations ## Test Infrastructure - Upgrade androidx.test:orchestrator from 1.4.2 to 1.5.0 - Modernize test assertions to use direct assertThat(Throwable) calls - Remove API 16 workaround comments and code ## Code Modernization - Remove obsolete SDK version checks (9 lint issues resolved) - Simplify file provider methods for API 21+ only - Update notification builder usage for modern APIs - Remove legacy view tree observer workarounds - Modernize layout and rendering code ## Resources & UI - Migrate drawable resources from selectors to Material ripple effects - Update themes from Holo to Material Design (API 21+ requirement) - Merge and remove obsolete -v21 resource folders - Modernize button and touch feedback using ripples ## Benefits - Access to Material Design components and APIs - Simplified codebase with removed legacy compatibility code - Enhanced test infrastructure with latest orchestrator - Improved user experience with modern UI patterns - Faster CI builds with fewer test matrix combinations ## Compatibility All modules now consistently require Android 5.0 (API 21, 2014) or higher. This affects minSdk but does not change the public API surface. Co-Authored-By: Claude <noreply@anthropic.com>
This commit migrates the entire LeakCanary project from minimum SDK API 21 to API 26, enabling modern Android features and further simplifying the codebase. API 26 corresponds to Android 8.0 (Oreo), released in 2017, providing over 7 years of Android compatibility while enabling notification channels and modern development practices. Changes included: ## Build Configuration - Update androidMinSdk from "21" to "26" in version catalog - Update hardcoded minSdk value in leakcanary-app from 21 to 26 - Update comment to reflect modern Android features requirement ## GitHub Actions / CI - Remove API 21 and API 23 from test matrix - Streamline CI to test only API 26+ (26, 31, 33, 34) - Improve CI efficiency with fewer test combinations ## Code Modernization - Simplify notification builder to always use notification channels (API 26+ requirement) - Remove obsolete PendingIntent FLAG_IMMUTABLE version checks (API 23+ always available) - Simplify instant app detection (API 26+ always supports this) - Remove obsolete SDK version checks for dynamic shortcuts (N_MR1 no longer relevant) - Modernize Context.getColor() usage (API 23+ always available) - Simplify process utilities in UiAutomator (API 23+ features always available) - Remove obsolete @TargetApi annotations for API levels below 26 ## Resources & UI - Move adaptive icons from mipmap-anydpi-v26 to mipmap-anydpi (no qualifier needed) - Move app launcher icons from drawable-v24 to drawable (API 26+ always supports adaptive icons) - Remove obsolete resource version qualifiers ## Code Cleanup - Remove unused import statements after version check removals - Simplify conditional logic where version checks became always true/false - Remove dead code branches for pre-API 26 compatibility ## Benefits - Access to notification channels (API 26 requirement) without compatibility code - Simplified codebase with removed legacy compatibility workarounds - Modern UI patterns with adaptive icons as standard - Faster CI builds with fewer test matrix combinations ## Compatibility All modules now consistently require Android 8.0 (API 26, 2017) or higher. This affects minSdk but does not change the public API surface. Library consumers benefit from simplified, more reliable notification handling. Co-Authored-By: Claude <noreply@anthropic.com>
blundell
commented
Feb 27, 2026
| return | ||
| } | ||
| // This fix was only needed for API 21, minimum SDK is now 26+ | ||
| return |
Contributor
Author
There was a problem hiding this comment.
@pyricau I'm not sure what to do here, you can see previously it returns if not on 21, and now its impossible to be on 21, but on the one hand its dead code, on the other these are kind of good documentation for anyone historically?
Member
There was a problem hiding this comment.
You can delete the whole MEDIA_SESSION_LEGACY_HELPER block then P)
Contributor
Author
There was a problem hiding this comment.
done, deleted all dead code based enums
With minSdkVersion now set to API 26 (Android 8.0), many of the Android leak fixes in the plumber module are no longer necessary as they targeted older API levels. This commit resolves lint warnings by adding early returns to obsolete fixes and removing unnecessary API annotations. Changes made: - AndroidLeakFixes.kt: Added early returns to 6 leak fixes that only applied to API levels below 26: • MEDIA_SESSION_LEGACY_HELPER (was for API 21) • FLUSH_HANDLER_THREADS (was for API 14-25) • LEAK_CANARY_THREAD_EDGE_CASE (was for API 21-25) • ACTIVITY_THREAD_EDGE_CASE (was for API 16-25) • CONNECTIVITY_MANAGER (was for API 21-25) - FixedWindowCallback.java: Removed obsolete @RequiresApi(23) annotation from onSearchRequested method - Cleaned up unused Build.VERSION imports after removing version checks These changes eliminate 11 ObsoleteSdkInt lint errors while maintaining API compatibility. The affected leak fixes are no longer needed since Android 8.0+ doesn't have these issues. Co-Authored-By: Claude <noreply@anthropic.com>
2d0e24d to
6f79d22
Compare
Removes 5 AndroidLeakFixes enum constants that are no longer needed with minimum SDK 26+: - MEDIA_SESSION_LEGACY_HELPER (API 21 only) - CONNECTIVITY_MANAGER (API ≤23 only) - ACTIVITY_MANAGER (Samsung API 22 only) - IMM_FOCUSED_VIEW (API ≤23 only) - SPELL_CHECKER (API 23 only) These fixes were already no-ops with early returns after the min SDK upgrade. Removing them completely eliminates ~200 lines of dead code and documentation while maintaining all functional leak fixes. The remaining 10 AndroidLeakFixes enum constants continue to provide useful leak fixes for Android 26+. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR modernizes LeakCanary by upgrading the minimum SDK from API 14 (Android 4.0 ICS, 2011) to API 26 (Android 8.0 Oreo, 2017), removing over 6 years of legacy compatibility code and enabling modern Android
features.
Summary
Combined, this represents a major modernization leap that simplifies the codebase while maintaining excellent market coverage (Android 8.0+ has >95% adoption).
Changes Overview
Build Configuration
GitHub Actions / CI Optimization
API 16, 19, 21, 23Code Modernization & Cleanup
Phase 1 (API 14→21) - Material Design Foundation
Phase 2 (API 21→26) - Modern Android Features
Resource & Asset Updates
Code Quality Improvements
Benefits
For LeakCanary Development
For Library Consumers
Compatibility Impact
Market Coverage Analysis
Testing
Migration Notes for Consumers
No action required - this change only affects the minimum supported Android version. Existing apps using LeakCanary will continue to work without changes.
For new integrations: Ensure your app targets Android 8.0+ (API 26+), which should already be the case for any modern Android development.
🎉 This modernization removes 6+ years of legacy Android compatibility code while maintaining excellent device coverage, positioning LeakCanary for the future of Android development!