@Nullable private CompileScope createFacetsCompileScope(@NotNull final CompilerManager compilerManager,@NotNull final VirtualFile[] files){
  final Set<Module> modules=New.set();
  boolean facetsFound=false;
  for (  final VirtualFile file : files) {
    final Module module=ModuleUtilCore.findModuleForFile(file,project);
    if (module != null) {
      modules.add(module);
      if (!facetsFound) {
        facetsFound=hasFacets(module);
      }
    }
  }
  if (facetsFound) {
    return compilerManager.createModulesCompileScope(modules.toArray(Module.EMPTY_ARRAY),true,true);
  }
  return null;
}

@ Nullable private CompileScope createFacetsCompileScope ( @ NotNull final CompilerManager compilerManager , @ NotNull final VirtualFile [ ] files ) { final Set < Module > modules = New . set ( ) ; boolean facetsFound = false ; for ( final VirtualFile file : files ) { final Module module = ModuleUtilCore . findModuleForFile ( file , project ) ; if ( module != null ) { modules . add ( module ) ; if ( ! facetsFound ) { facetsFound = hasFacets ( module ) ; } } } if ( facetsFound ) { return compilerManager . createModulesCompileScope ( modules . toArray ( Module . EMPTY_ARRAY ) , true , true ) ; } return null ; }
it seems that createfilescompilescope does not work in all environments , at least with android , see https : / / intellij - support . jetbrains . com / hc / en - us / community / posts / 207521525 - compilermanager - make - does - not - all - tasks - in - case - of - a - android - module - project < p > we choose a very defensive solution and use createmodulescompilescope when we detect a facet .
