Native assets support for Android Add2app (#140802)

Support for FFI calls with @Native external functions through Native assets on Android add to app. This enables bundling native code without any build-system boilerplate code.

For more info see:

*  https://github.com/flutter/flutter/issues/129757

## Implementation details for Android add2app

The `.so` files are bundled with the same mechanism that bundles `libapp.so`.
This commit is contained in:
Daco Harkes
2024-01-09 09:47:53 +01:00
committed by GitHub
parent 29db9dbd44
commit b2ef2802d2
6 changed files with 52 additions and 114 deletions

View File

@@ -78,7 +78,6 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
Uri? yamlParentDirectory,
required FileSystem fileSystem,
required int targetAndroidNdkApi,
bool isAndroidLibrary = false,
}) async {
const OS targetOS = OS.android;
final Uri buildUri_ = nativeAssetsBuildUri(projectUri, targetOS);
@@ -115,9 +114,6 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
}
ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.');
if (isAndroidLibrary && nativeAssets.isNotEmpty) {
throwToolExit('Native assets are not yet supported in Android add2app.');
}
final Map<Asset, Asset> assetTargetLocations =
_assetTargetLocations(nativeAssets);
await _copyNativeAssetsAndroid(buildUri_, assetTargetLocations, fileSystem);