Skip to content

bug: Application crashes (only Android 8.1 and below and flet 0.81.0 and later) #6619

Closed
flet-dev/serious-python
#219

Description

@r58uoi

Duplicate Check

Describe the bug

When I create an application using flet for Android and install modern smartphones or tablets, but I know that it is possible to install at least Android 7. I tried to install an application of older Android versions, but I saw that Android 8.1 and older versions cause the application to crash.

But... I experimented and found out that flet version 0.80.5 and older versions do not crash the application. When the flet 0.81.0 update was released, the app started to fail in older versions of Android.

I do not know, maybe this is not a bug, or android is outdated? I think flet 0.81.0 and later versions do not support older Android versions.

Code sample

Code
[Paste your code here]
import flet as ft


def main(page: ft.Page):
    counter = ft.Text("0", size=50, data=0)

    def increment_click(e):
        counter.data += 1
        counter.value = str(counter.data)

    page.floating_action_button = ft.FloatingActionButton(
        icon=ft.Icons.ADD, on_click=increment_click
    )
    page.add(
        ft.SafeArea(
            expand=True,
            content=ft.Container(
                content=counter,
                alignment=ft.Alignment.CENTER,
            ),
        )
    )


ft.run(main)

To reproduce

1.Create a project: flet create myapp
2.Build an apk project: flet build apk myapp
3.Install the app using Android 8.1 and older versions (via android studio or an old phone that costs Android 8.1 and older)
4.Now, open the app

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Screen_recording_20260626_235606.mp4

Operating System

Windows

Operating system details

10 Pro

Flet version

0.85.3

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Activity

  1. FeodorFitsner commented on Jun 26, 2026

    @FeodorFitsner
    Contributor

    Looking into that.

  2. FeodorFitsner commented on Jun 27, 2026

    @FeodorFitsner
    Contributor

    Thanks for the detailed report and the exact version boundary — that was the key to tracking this down. I reproduced it and found the root cause.

    What's happening

    This is not a "Flet dropped old Android" issue and not a rendering/Impeller issue. The app crashes on launch on Android 8.1 and below (API < 28) with:

    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/graphics/ImageDecoder$OnHeaderDecodedListener;
      at com.flet.serious_python_android.AndroidPlugin.onMethodCall(...)
    Caused by: java.lang.ClassNotFoundException: android.graphics.ImageDecoder$OnHeaderDecodedListener
    

    serious_python_android's getAppVersion handler — which runs on every app startup — calls PackageInfo.getLongVersionCode(), an API 28+ method, unconditionally. In release builds, R8 outlines that call into a synthetic class and merges into it the API-28 outlines from Flutter 3.41's new ImageDecoderDefaultImpl (which uses android.graphics.ImageDecoder). Invoking the version-code method on API < 28 forces that merged class to load, its ImageDecoder references fail to resolve, and the app crashes.

    That explains the exact regression boundary: Flet 0.80.5 shipped Flutter 3.38.7 (no ImageDecoderDefaultImpl); Flet 0.81.0 bumped to Flutter 3.41.2, which added it. The unguarded getLongVersionCode() was always there, but only became fatal once Flutter contributed an ImageDecoder outline for R8 to merge with.

    Verified on emulators with a stock flet create counter app (release APK): crashes on Android 8.0 / API 26, runs fine on Android 10 / API 29.

    Fix

    PR: flet-dev/serious-python#219 (guards the call with Build.VERSION.SDK_INT, falling back to the deprecated versionCode int on API < 28).

    Workaround now (Flet 0.81.0–0.85.x)

    Until a fixed serious_python is released, add this to your pyproject.toml to build against a patched branch, then rebuild with flet build apk. Note both entries are required — serious_python_android pulls in serious_python_platform_interface, so they must share the same source:

    [tool.flet.flutter.pubspec.dependency_overrides.serious_python_android]
    git = { url = "https://github.com/flet-dev/serious-python.git", ref = "fix/android-old-version-crash-1.0.1", path = "src/serious_python_android" }
    
    [tool.flet.flutter.pubspec.dependency_overrides.serious_python_platform_interface]
    git = { url = "https://github.com/flet-dev/serious-python.git", ref = "fix/android-old-version-crash-1.0.1", path = "src/serious_python_platform_interface" }

    I verified this override end-to-end: with it, the counter app launches and runs correctly on Android 8.0 (API 26).

  3. moved this from 👀 In review to ✅ Done in Flet Developmenton Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions