@@ -560,6 +560,15 @@ task compileAppClassesForSbg {
560560 outputs. dir(outDir)
561561
562562 doLast {
563+ // Created FIRST, and unconditionally: this directory is written into
564+ // sbg-java-dependencies.txt whether or not anything lands in it, and the
565+ // generator does File.listFiles() on every entry there. A missing
566+ // directory returns null and it dies with a NullPointerException in
567+ // FileSystemHelperImpl.readClassesFromDirectory, blaming nothing.
568+ // An app with no Java of its own -- most of them -- reaches that.
569+ outDir. deleteDir()
570+ outDir. mkdirs()
571+
563572 def sources = []
564573 sourceRoot. eachFileRecurse { f ->
565574 if (f. isFile() && f. name. endsWith(" .java" )
@@ -572,9 +581,6 @@ task compileAppClassesForSbg {
572581 return
573582 }
574583
575- outDir. deleteDir()
576- outDir. mkdirs()
577-
578584 // The classpath collectAllJars just wrote, plus whatever the runtime
579585 // module has already produced -- com.tns.* is what the app's own
580586 // classes extend.
@@ -849,7 +855,15 @@ task 'collectAllJars' {
849855 allJarPaths. each { out. println it }
850856 // The app's own classes, compiled by compileAppClassesForSbg. A
851857 // directory rather than a jar; the generator reads both.
852- out. println layout. buildDirectory. dir(" nativescript/sbg-app-classes" ). get(). asFile. absolutePath
858+ //
859+ // Listed ONLY when that task runs, which is the same napi gate runSbg
860+ // uses. The generator does File.listFiles() on every entry here and
861+ // walks the result without a null check, so naming a directory nobody
862+ // produced kills it with a NullPointerException out of
863+ // FileSystemHelperImpl.readClassesFromDirectory, blaming nothing.
864+ if (napiEngine != null ) {
865+ out. println layout. buildDirectory. dir(" nativescript/sbg-app-classes" ). get(). asFile. absolutePath
866+ }
853867 }
854868 new File (" $BUILD_TOOLS_PATH /$MDG_JAVA_DEPENDENCIES " ). withWriter { out ->
855869 allJarPaths. each {
0 commit comments