@Test public void testFindLocalJavaSdk() { try { File dir = LocalAndroidPlatforms.findLocalJavaSdk(); System.out.println("Local Android SDK Dir = " + dir); if (dir != null) { LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(dir); System.out.println("LocalAndroidPlatforms = " + platforms); } } catch (IOException e) { e.printStackTrace(); } }
public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); }
LocalAndroidPlatforms { public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); } }
LocalAndroidPlatforms { public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); } LocalAndroidPlatforms(File dir); }
LocalAndroidPlatforms { public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); } LocalAndroidPlatforms(File dir); static File findLocalJavaSdk(); @Override String toString(); void addPlatform(AndroidPlatform platform); boolean valid(); boolean exists(); AndroidPlatform getPlatform(String id); Collection<AndroidPlatform> getPlatforms(); int getSdkRelease(); int size(); File getDir(); File getBin(String binname); boolean hasApiLevel(String apilevel); }
LocalAndroidPlatforms { public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); } LocalAndroidPlatforms(File dir); static File findLocalJavaSdk(); @Override String toString(); void addPlatform(AndroidPlatform platform); boolean valid(); boolean exists(); AndroidPlatform getPlatform(String id); Collection<AndroidPlatform> getPlatforms(); int getSdkRelease(); int size(); File getDir(); File getBin(String binname); boolean hasApiLevel(String apilevel);  }