Provide a more helpful error message in the case of UnsatisfiedLinkError (flutter/engine#50247)

Related https://github.com/flutter/flutter/issues/83596
This commit is contained in:
John McCutchan
2024-02-01 11:04:45 -08:00
committed by GitHub
parent eff9aac24a
commit 7c04b55f07

View File

@@ -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;
}