Skip to content

Commit 2032404

Browse files
committed
AndroidPlatform, AndroidHelper: validate that the ANDROID_SDK, ANDROID_NDK_ROOT, and JAVA_HOME paths exist and are directories
Better to display an error early with the exact cause of the problem rather than letting it become an issue later
1 parent 59701ee commit 2032404

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/lime/tools/AndroidHelper.hx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ class AndroidHelper
189189

190190
if (project.environment.exists("JAVA_HOME"))
191191
{
192+
var javaHome = project.environment.get("JAVA_HOME");
193+
if (!FileSystem.exists(javaHome))
194+
{
195+
Log.error("The path specified for JAVA_HOME does not exist: " + javaHome);
196+
Sys.exit(1);
197+
}
198+
if (!FileSystem.isDirectory(javaHome))
199+
{
200+
Log.error("The path specified for JAVA_HOME must be a directory: " + javaHome);
201+
Sys.exit(1);
202+
}
192203
Sys.putEnv("JAVA_HOME", project.environment.get("JAVA_HOME"));
193204
}
194205
}

tools/platforms/AndroidPlatform.hx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,31 @@ class AndroidPlatform extends PlatformTarget
519519
Log.error("You must define ANDROID_SDK and ANDROID_NDK_ROOT to target Android, please run '" + command + " setup android' first");
520520
Sys.exit(1);
521521
}
522+
else
523+
{
524+
var sdkPath = project.environment.get("ANDROID_SDK");
525+
if (!FileSystem.exists(sdkPath))
526+
{
527+
Log.error("The path specified for ANDROID_SDK does not exist: " + sdkPath);
528+
Sys.exit(1);
529+
}
530+
if (!FileSystem.isDirectory(sdkPath))
531+
{
532+
Log.error("The path specified for ANDROID_SDK must be a directory: " + sdkPath);
533+
Sys.exit(1);
534+
}
535+
var ndkPath = project.environment.get("ANDROID_NDK_ROOT");
536+
if (!FileSystem.exists(ndkPath))
537+
{
538+
Log.error("The path specified for ANDROID_NDK_ROOT does not exist: " + ndkPath);
539+
Sys.exit(1);
540+
}
541+
if (!FileSystem.isDirectory(ndkPath))
542+
{
543+
Log.error("The path specified for ANDROID_NDK_ROOT must be a directory: " + ndkPath);
544+
Sys.exit(1);
545+
}
546+
}
522547

523548
if (project.config.exists("android.gradle-build-directory"))
524549
{

0 commit comments

Comments
 (0)