Modernize legacy Leanback sample: Upgrade Gradle/SDK and migrate to Media3#225
Modernize legacy Leanback sample: Upgrade Gradle/SDK and migrate to Media3#225pflammertsma wants to merge 5 commits into
Conversation
- Migrate VideoPlayerGlue and PlaybackFragment from deprecated ExoPlayer 2 to AndroidX Media3. - Add android:exported="true" to launcher activities in AndroidManifest.xml for Android 12+ compatibility. - Add PendingIntent.FLAG_IMMUTABLE in RecommendationReceiver for Android 12+ alarm mutability compliance. - Resolve static analysis and lint warnings (add hashCode() to Video, specify Locale.ROOT in VideoProvider, pass parent ViewGroup to inflate in IconHeaderItemPresenter, fix array declaration syntax). TAG=agy CONV=c90143f0-3646-4a01-89f5-44a5938a65f2
There was a problem hiding this comment.
Code Review
This pull request modernizes the Leanback sample application by upgrading the target SDK to 35, updating Gradle to version 8.7, migrating from legacy ExoPlayer to AndroidX Media3, and introducing a central dependency catalog. It also adds a script to automate screenshot generation. The review feedback highlights several areas for improvement: fully disabling the deprecated recommendation service to prevent background crashes on API 31+, removing commented-out and dead code in MainFragment, using requireContext() and properly detaching PlaybackGlue in PlaybackFragment to avoid null pointer exceptions and memory leaks, and fixing a potential crash in the screenshot script when arguments are missing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
af9d286 to
ca9a08f
Compare
…a3, and remove obsolete recommendations - Upgrade Gradle to 8.7, AGP to 8.6.0, and JDK to 21, targeting SDK 35. - Migrate video playback to AndroidX Media3 (1.9.0). - Completely remove the obsolete and crashing recommendations functionality (androidx.recommendation library, RecommendationReceiver, and UpdateRecommendationsService). - Fix compilation issues in SettingsFragment.java and resource resolutions. - Use requireContext() and requireActivity() instead of getActivity() in PlaybackFragment for null-safety. - Detach PlaybackGlue from its host in PlaybackFragment when releasing the player to prevent memory leaks. - Improve robustness of capture_screenshots.sh with argument validation for the serial flag. - Regenerate all screenshots at 1080p.
8faa72a to
909f873
Compare
This PR modernizes the legacy Java-based
Leanbacksample app to ensure it compiles and runs correctly on modern Android developer environments and devices, preparing it to serve as a stable "before" baseline for the Compose migration.Key Changes
compileSdkandtargetSdkto 35.SettingsFragment.javarelated to thefindPreferenceAPI signature.buildConfigand configured non-transitive R classes (android.nonTransitiveRClass=false) to resolve legacy resource compilation issues.UpdateRecommendationsServiceon app launch. This service relied on the deprecatedandroidx.recommendationlibrary which throws fatalIllegalArgumentExceptions when targeting API 31+ due to missingPendingIntentmutability flags.capture_screenshots.shwith increased delays to ensure stable UI loading before capturing, and regenerated all 10 screenshots at 1080p (1920x1080).