From 7c04b55f07ab110d8b5d34730f46faeda46c4445 Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Thu, 1 Feb 2024 11:04:45 -0800 Subject: [PATCH] Provide a more helpful error message in the case of UnsatisfiedLinkError (flutter/engine#50247) Related https://github.com/flutter/flutter/issues/83596 --- .../io/flutter/embedding/engine/FlutterJNI.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java index 756298a777..1196262ca5 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java @@ -142,7 +142,20 @@ public class FlutterJNI { Log.w(TAG, "FlutterJNI.loadLibrary called more than once"); } - System.loadLibrary("flutter"); + try { + System.loadLibrary("flutter"); + } catch (UnsatisfiedLinkError e) { + // Sniff if this because libflutter.so couldn't be found. + if (e.toString().contains("couldn't find \"libflutter.so\"")) { + throw new UnsupportedOperationException( + "Could not load libflutter.so this is likely because the application" + + " is running on an architecture that Flutter Android does not support (e.g. x86)" + + " see https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures" + + " for more detail.", + e); + } + throw e; + } FlutterJNI.loadLibraryCalled = true; }