diff --git a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl index 2a9ed9b981..eb1f02bc59 100644 --- a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/CMakeLists.txt.tmpl @@ -15,3 +15,8 @@ set_target_properties({{projectName}} PROPERTIES ) target_compile_definitions({{projectName}} PUBLIC DART_SHARED_LIB) + +if(ANDROID) + # Support Android 15 16k page size + target_link_options({{projectName}} PRIVATE "-Wl,-z,max-page-size=16384") +endif() diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index 391c51fd6b..7c0ee8963e 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -3149,6 +3149,33 @@ void main() { expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true); }); + testUsingContext('Android FFI plugin contains 16kb page support', () async { + Cache.flutterRoot = '../..'; + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run([ + 'create', + '--no-pub', + '-t', + 'plugin_ffi', + '--org', + 'com.bar.foo', + '--platforms=android', + projectDir.path + ]); + + final File cmakeLists = + globals.fs.file('${projectDir.path}/src/CMakeLists.txt'); + + expect(cmakeLists.existsSync(), true); + + final String cmakeListsContent = await cmakeLists.readAsString(); + const String expected16KbFlags = 'PRIVATE "-Wl,-z,max-page-size=16384")'; + expect(cmakeListsContent, contains(expected16KbFlags)); + }); + testUsingContext('Android Kotlin plugin contains namespace', () async { Cache.flutterRoot = '../..';