❌ the local Lottie asset fails to display in a deployed APK,
❌ src for lottie asset is different on LINUX app vs APK app
✅ if src is a URL lottie asset renders correctly in both APK and LINUX app
✅ Image assets (png) render correctly in both APK and LINUX app
I've verified that the file B.json is indeed present in the APK app.zip. However the assets folder is not present in the temporary flutter build folder nor is the assets dir present in the pubspec.yaml
in modifying the flet build as follows I can make it work
diff --git a/sdk/python/packages/flet/src/flet/cli/commands/build.py b/sdk/python/packages/flet/src/flet/cli/commands/build.py
index 0006751..5f28698 100644
--- a/sdk/python/packages/flet/src/flet/cli/commands/build.py
+++ b/sdk/python/packages/flet/src/flet/cli/commands/build.py
@@ -432,6 +432,35 @@ class Command(BaseCommand):
print("Customizing app icons and splash images...", end="")
assets_path = python_app_path.joinpath("assets")
if assets_path.exists():
+ if target_platform == "apk":
+ # Configure in APK for assets and update pubspec.yaml
+ # TODO: I expect this should apply to abb as well
+ flutter_apk_assets_dir = "assets"
+ flutter_apk_assets_path = self.flutter_dir / flutter_apk_assets_dir
+ flutter_apk_assets_path.mkdir(exist_ok=True)
+
+ def ignore_files(dir, files):
+ # TODO: understand what should be excluded or included
+ return [f for f in files if f.endswith(".png") or f == "temp"]
+
+ print(
+ f"\nCopying additional APK assets: {str(flutter_apk_assets_path)}"
+ )
+
+ # copy `assets` directory contents to the output directory ignoring some files
+ copy_tree(
+ str(assets_path), str(flutter_apk_assets_path), ignore=ignore_files
+ )
+
+ print(
+ f'PreBuild pubspec.yaml flutter assets: {pubspec["flutter"]["assets"]}'
+ )
+ if f"{flutter_apk_assets_dir}/" not in pubspec["flutter"]["assets"]:
+ print(f"adding {flutter_apk_assets_dir}/ to pubspec.yaml")
+ pubspec["flutter"]["assets"].append(f"{flutter_apk_assets_dir}/")
+ print(
+ f'Build pubspec.yaml flutter assets: {pubspec["flutter"]["assets"]}'
+ )
+
images_dir = "images"
images_path = self.flutter_dir.joinpath(images_dir)
images_path.mkdir(exist_ok=True)
Environment:
Flet version: 0.22.0
Android SDK version: android-33
NDK version: 25.2.9519653
Python-for-Android Distribution: 2024.01.21
Steps to Reproduce:
Example Lottie Assets are downloaded and managed with the following script commands:
# expect ./assets and ./assets/images directories to already exist
wget https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/B.json" -O assets/B.json
cp ./assets/B.json ./assets/images/B.json
Build process includes setting up Android and NDK environments and using flet build apk with specified parameters.
Deploy the APK to an Android device and test the renderering the local APK delivered Lottie file.
Expected Behavior:
The Lottie asset B.json should render as it does in the local linux development environment.
local Lottie asset src should be consistent across target deployments ie Linux
Actual Behavior:
The Lottie local asset does not render in the deployed APK,
while other assets such as local PNG's and Lottie URL asset appear correctly.
Code Example:
Here is the relevant portion of code where the Lottie assets are consumed for intended to display:
In the spirit of keeping this issue as brief as possible, the code is in a gist , The following gist creates a series of cards to find what permutations work and what if any errors are able to be captured see
https://gist.github.com/auphof/32f4f22328374d4e13ebc5a28206fb13
# The following gist creates a series of cards to find what permutations work and
# what if any errors are able to be captured
# see https://gist.github.com/auphof/32f4f22328374d4e13ebc5a28206fb13
# Following work with modified build for ✅APK but not in ❌ WSL
lottie_card_b0 = create_lottie_card("B0", src="./assets/B.json")
lottie_card_b1 = create_lottie_card("B1", src="assets/B.json")
# Following Fail still fail with modified ❌ APK but work in ✅ WSL
lottie_card_b2 = create_lottie_card("B2", src="B.json")
lottie_card_b5 = create_lottie_card("B5", src="/B.json")
lottie_card_b6 = create_lottie_card("B6", src="/images/B.json")
# Following still fail with modified ❌ APK and fail in ❌ WSL
lottie_card_b3 = create_lottie_card("B3", src="/assets/B.json")
Additional Context:
The application is developed and tested in a Windows Subsystem for Linux (WSL) environment where everything functions as expected.
Only the local Lottie asset fails to render, despite being present in the APK as confirmed via APK inspection.
Issue Description: I am developing an Android application using Flet, where I'm trying to display a local Lottie asset (
B.json
) within a deployed APK.I've verified that the file
B.json
is indeed present in the APKapp.zip
. However the assets folder is not present in the temporary flutter build folder nor is theassets
dir present in thepubspec.yaml
in modifying the flet build as follows I can make it work
Environment:
Steps to Reproduce:
flet build apk
with specified parameters.Expected Behavior: The Lottie asset
B.json
should render as it does in the local linux development environment. local Lottie assetsrc
should be consistent across target deployments ie LinuxActual Behavior: The Lottie local asset does not render in the deployed APK, while other assets such as local PNG's and Lottie URL asset appear correctly.
Code Example: Here is the relevant portion of code where the Lottie assets are consumed for intended to display: In the spirit of keeping this issue as brief as possible, the code is in a gist , The following gist creates a series of cards to find what permutations work and what if any errors are able to be captured see https://gist.github.com/auphof/32f4f22328374d4e13ebc5a28206fb13
Additional Context:
Attempts to Resolve:
Any insights or alternative suggestions on how to resolve this issue would be greatly appreciated!