This section outlines how to override media-kit dependencies to fix 16KB page size support for Android.
Override the media-kit dependencies with a custom fork that updates the NDK version to 28.2.13676358 and compileSdkVersion to 36 as well as gradle version to 8.6.0.
Add these dependencies to your pubspec.yaml:
dependencies:
# Standard video dependencies
video_player: ^2.9.2
video_player_media_kit: ^1.0.6
media_kit_libs_android_video: any
dependency_overrides:
# Replace video_player_media_kit and its core dependencies with GitHub version
video_player_media_kit:
git:
url: https://github.com/ndungudedan/media-kit.git
path: video_player_media_kit
ref: main
# Core dependency
media_kit:
git:
url: https://github.com/ndungudedan/media-kit.git
path: media_kit
ref: main
# Core Video dependency
media_kit_video:
git:
url: https://github.com/ndungudedan/media-kit.git
path: media_kit_video
ref: main
media_kit_libs_android_video:
git:
url: https://github.com/ndungudedan/media-kit.git
path: libs/android/media_kit_libs_android_video
ref: main
# Add other relevant overrides here- This happens when using the packages
media_kiton recent Android versions. Confirmed on Android 14 and 15. - Removing the
media_kitdependency fixes the issue, but breaks the video player on older Android versions. Confirmed on Android 10.
- Conditional integration of media kit based on the Android version. Sample code below,
main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
final sdkInt = (await DeviceInfoPlugin().androidInfo).version.sdkInt;
// Use media kit on Android 10 and older
if (sdkInt <= 29) {
await VideoPlayerMediaKit.ensureInitialized(
android: true,
);
}
}
}