androidEagerLibs function

List<String> androidEagerLibs(
  1. List<ModuleInfo> modules,
  2. Set<String> androidCppLibs, {
  3. String baseDir = '.',
})

The libraries the Kotlin plugin loads when the app starts: Kotlin modules (their JniBridge needs the library's JNI exports). An Android C++ module is left to Dart's DynamicLibrary.open on first use, which also runs its static constructors (where the impl registers), so the app does not pay ~0.8 ms per library before its first frame. ART resolves external functions only in libraries System.loadLibrary loaded, so a plugin whose own C/C++ sources define JNI entry points keeps every library eager.

Implementation

List<String> androidEagerLibs(List<ModuleInfo> modules, Set<String> androidCppLibs, {String baseDir = '.'}) {
  if (_pluginDefinesJni(baseDir)) return [for (final m in modules) m.lib];
  return [for (final m in modules) if (!androidCppLibs.contains(m.lib)) m.lib];
}