diff --git a/.fvmrc b/.fvmrc index efcdf3cd..5913bec0 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.44.3" + "flutter": "3.44.4" } \ No newline at end of file diff --git a/src/serious_python_android/CHANGELOG.md b/src/serious_python_android/CHANGELOG.md index e8022c7a..1956a71a 100644 --- a/src/serious_python_android/CHANGELOG.md +++ b/src/serious_python_android/CHANGELOG.md @@ -1,5 +1,6 @@ ## 4.1.1 +* Fix app crashing on launch on Android 8.1 and below (API < 28). The `getAppVersion` method-channel handler, called on every startup, used `PackageInfo.getLongVersionCode()` (API 28+) unconditionally. R8 outlines this call into a synthetic class that it can merge with other API 28+ outlines — notably Flutter 3.41's `ImageDecoder`-based image decoder — and invoking that merged class on API < 28 fails verification with `NoClassDefFoundError: android.graphics.ImageDecoder$OnHeaderDecodedListener`. The call is now guarded with a `Build.VERSION.SDK_INT` check, falling back to the deprecated `versionCode` int field on older devices. * Fix the embedded interpreter crashing on startup on a **non-primary ABI** (e.g. an x86_64 emulator when `arm64-v8a` is the primary ABI) with `ModuleNotFoundError: No module named '_sysconfigdata__android_-linux-android'`. The ABI-common `stdlib.zip` was built from the primary ABI only, dropping every other ABI's arch-specific `_sysconfigdata__android_` module — which CPython imports at startup via `sysconfig` (pulled in by `ctypes`). The primary `splitStdlib` task now also harvests each other ABI's `_sysconfigdata__android_` into `stdlib.zip` (only that arch-specific module, so the generic ABI-identical `_sysconfigdata__linux_` shipped by some versions like 3.12 isn't duplicated). ## 4.1.0 diff --git a/src/serious_python_android/android/src/main/java/com/flet/serious_python_android/AndroidPlugin.java b/src/serious_python_android/android/src/main/java/com/flet/serious_python_android/AndroidPlugin.java index bb9c636b..238401af 100644 --- a/src/serious_python_android/android/src/main/java/com/flet/serious_python_android/AndroidPlugin.java +++ b/src/serious_python_android/android/src/main/java/com/flet/serious_python_android/AndroidPlugin.java @@ -122,7 +122,16 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { android.content.pm.PackageManager pm = context.getPackageManager(); android.content.pm.PackageInfo info = pm.getPackageInfo(packageName, 0); String versionName = info.versionName; - long versionCode = info.getLongVersionCode(); + // PackageInfo.getLongVersionCode() is API 28+. Calling it unconditionally + // makes the Android Gradle plugin (R8) outline the call into a synthetic + // class that it may merge with other API 28+ outlines (e.g. Flutter's + // ImageDecoder-based image decoder). Invoking that merged class on + // API < 28 fails verification with NoClassDefFoundError and crashes the + // app on launch, because getAppVersion runs on every startup. Guard the + // call so older devices use the deprecated int field instead. + long versionCode = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) + ? info.getLongVersionCode() + : (long) info.versionCode; result.success(versionName + "+" + versionCode); } catch (Exception e) { result.error("Error", e.getMessage(), null);