Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e5215e6

Browse files
authored
More logs for Android unsatisfiedLinkError (#53920)
See flutter/flutter#83596 (comment), there are two cases: 1. IO issue 2. The directory doesn't exist Narrow down by including in the logs if the directory exists or not. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 738274a commit e5215e6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ public InitResult call() {
207207
+ cpuArch
208208
+ ", and the native libraries directory (with path "
209209
+ nativeLibsDir.getAbsolutePath()
210-
+ ") contains the following files: "
211-
+ Arrays.toString(nativeLibsContents),
210+
+ ") "
211+
+ (nativeLibsDir.exists()
212+
? "contains the following files: "
213+
+ Arrays.toString(nativeLibsContents)
214+
: "does not exist."),
212215
unsatisfiedLinkError);
213216
}
214217

shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.junit.Test;
3535
import org.junit.runner.RunWith;
3636
import org.mockito.ArgumentCaptor;
37+
import org.mockito.Mockito;
3738
import org.robolectric.annotation.Config;
3839

3940
@Config(manifest = Config.NONE)
@@ -61,6 +62,25 @@ public void itReportsInitializedAfterInitializing() {
6162
verify(mockFlutterJNI, times(1)).updateRefreshRate();
6263
}
6364

65+
@Test
66+
public void unsatisfiedLinkErrorPathDoesNotExist() {
67+
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
68+
ctx.getApplicationInfo().nativeLibraryDir = "/path/that/doesnt/exist";
69+
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
70+
71+
Mockito.doThrow(new UnsatisfiedLinkError("couldn't find \"libflutter.so\""))
72+
.when(mockFlutterJNI)
73+
.loadLibrary();
74+
try {
75+
flutterLoader.startInitialization(ctx);
76+
} catch (UnsupportedOperationException e) {
77+
assertTrue(
78+
e.getMessage()
79+
.contains(
80+
"and the native libraries directory (with path /path/that/doesnt/exist) does not exist."));
81+
}
82+
}
83+
6484
@Test
6585
public void itDefaultsTheOldGenHeapSizeAppropriately() {
6686
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);

0 commit comments

Comments
 (0)