Skip to content

Commit b038ce3

Browse files
Fix Android SDK path detection in CI container environment
Updated `AndroidGradleBuilder.java` to improve SDK path detection. Instead of assuming any `ANDROID_HOME` path that doesn't end in "sdk" must be a parent directory, the builder now validates the directory content (checking for `platform-tools`, `build-tools`, etc.) before modifying the path. This change ensures compatibility with the new CI container layout where `ANDROID_HOME` points directly to the SDK root at `/opt/android-sdk` (or `/opt/android/sdk`) without forcing an incorrect `/sdk` suffix.
1 parent a01e66a commit b038ce3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/AndroidGradleBuilder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,13 @@ public boolean build(File sourceZip, final BuildRequest request) throws BuildExc
577577
if (!androidSDKDir.exists()) {
578578
throw new BuildException("Cannot find Android SDK at "+androidHome+". Please install Android studio, or set the ANDROID_HOME environment variable to point to your android sdk directory.");
579579
}
580-
if (!androidSDKDir.getName().equalsIgnoreCase("sdk")) {
580+
581+
boolean looksLikeSdk = new File(androidSDKDir, "platform-tools").exists() ||
582+
new File(androidSDKDir, "build-tools").exists() ||
583+
new File(androidSDKDir, "cmdline-tools").exists() ||
584+
new File(androidSDKDir, "platforms").exists();
585+
586+
if (!looksLikeSdk && !androidSDKDir.getName().equalsIgnoreCase("sdk")) {
581587
androidSDKDir = new File(androidSDKDir, "Sdk");
582588
if (!androidSDKDir.isDirectory()) {
583589
androidSDKDir = new File(androidSDKDir.getParentFile(), "sdk");

0 commit comments

Comments
 (0)