More logs for Android unsatisfiedLinkError (flutter/engine#53920)

See https://github.com/flutter/flutter/issues/83596#issuecomment-2140605278, 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
This commit is contained in:
Gray Mackall 2024-07-16 13:12:03 -07:00 committed by GitHub
parent 4cf29c3de0
commit 29a474fe3e
2 changed files with 25 additions and 2 deletions

View File

@ -207,8 +207,11 @@ public class FlutterLoader {
+ cpuArch
+ ", and the native libraries directory (with path "
+ nativeLibsDir.getAbsolutePath()
+ ") contains the following files: "
+ Arrays.toString(nativeLibsContents),
+ ") "
+ (nativeLibsDir.exists()
? "contains the following files: "
+ Arrays.toString(nativeLibsContents)
: "does not exist."),
unsatisfiedLinkError);
}

View File

@ -34,6 +34,7 @@ import java.util.concurrent.ExecutorService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.robolectric.annotation.Config;
@Config(manifest = Config.NONE)
@ -61,6 +62,25 @@ public class FlutterLoaderTest {
verify(mockFlutterJNI, times(1)).updateRefreshRate();
}
@Test
public void unsatisfiedLinkErrorPathDoesNotExist() {
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
ctx.getApplicationInfo().nativeLibraryDir = "/path/that/doesnt/exist";
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
Mockito.doThrow(new UnsatisfiedLinkError("couldn't find \"libflutter.so\""))
.when(mockFlutterJNI)
.loadLibrary();
try {
flutterLoader.startInitialization(ctx);
} catch (UnsupportedOperationException e) {
assertTrue(
e.getMessage()
.contains(
"and the native libraries directory (with path /path/that/doesnt/exist) does not exist."));
}
}
@Test
public void itDefaultsTheOldGenHeapSizeAppropriately() {
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);