Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,7 @@ public void loadLibrary() {
Log.w(TAG, "FlutterJNI.loadLibrary called more than once");
}

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;
}
System.loadLibrary("flutter");
FlutterJNI.loadLibraryCalled = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,37 @@ public InitResult call() {
try (TraceSection e = TraceSection.scoped("FlutterLoader initTask")) {
ResourceExtractor resourceExtractor = initResources(appContext);

flutterJNI.loadLibrary();
try {
flutterJNI.loadLibrary();
} catch (UnsatisfiedLinkError unsatisfiedLinkError) {
String couldntFindVersion = "couldn't find \"libflutter.so\"";
String notFoundVersion = "dlopen failed: library \"libflutter.so\" not found";

if (unsatisfiedLinkError.toString().contains(couldntFindVersion)
|| unsatisfiedLinkError.toString().contains(notFoundVersion)) {
// To gather more information for
// https://github.com/flutter/flutter/issues/144291,
// log the contents of the native libraries directory as well as the
// cpu architecture.

String cpuArch = System.getProperty("os.arch");
String[] nativeLibs = new File(flutterApplicationInfo.nativeLibraryDir).list();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you filter this list down to just files that end with .so or change the message below on line 208?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change the message to the following files (I suppose I was assuming only .so files end up there because thats all I saw when I tested it, but that is probably a bad assumption)


throw new UnsupportedOperationException(
"Could not load libflutter.so this is possibly 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.\n"
+ "App is using cpu architecture: "
+ cpuArch
+ ", and the native libraries directory contains the following files: "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include the native library directory path in this message? Or if the files in nativeLibs are absolute paths that no need to do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see this before the merge, sorry. The files aren't shown as absolute paths, I'll put up a quick follow up to print the path too

+ Arrays.toString(nativeLibs),
unsatisfiedLinkError);
}

throw unsatisfiedLinkError;
}

flutterJNI.updateRefreshRate();

// Prefetch the default font manager as soon as possible on a background thread.
Expand Down