private static void doCollectResourceDirs(
      AndroidFacet facet,
      boolean collectResCacheDirs,
      List<String> result,
      CompileContext context) {
    final Module module = facet.getModule();

    if (collectResCacheDirs) {
      final AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
      final int platformToolsRevision =
          platform != null ? platform.getSdk().getPlatformToolsRevision() : -1;

      if (platformToolsRevision < 0 || platformToolsRevision > 7) {
        // png cache is supported since platform-tools-r8
        final String resCacheDirOsPath = findResourcesCacheDirectory(module, false, context);
        if (resCacheDirOsPath != null) {
          result.add(resCacheDirOsPath);
        } else {
          LOG.info("PNG cache not found for module " + module.getName());
        }
      }
    }

    final VirtualFile resourcesDir = AndroidAptCompiler.getResourceDirForApkCompiler(module, facet);
    if (resourcesDir != null) {
      result.add(resourcesDir.getPath());
    }
  }
  private void createAndAlignApk(final String apkPath) {
    AndroidPlatform platform = myWizard.getFacet().getConfiguration().getAndroidPlatform();
    assert platform != null;
    String sdkPath = platform.getSdkData().getLocation();
    String zipAlignPath =
        sdkPath + File.separatorChar + AndroidSdkUtils.toolPath(SdkConstants.FN_ZIPALIGN);
    File zipalign = new File(zipAlignPath);
    final boolean runZipAlign = zipalign.isFile();
    File destFile = null;
    try {
      destFile = runZipAlign ? FileUtil.createTempFile("android", ".apk") : new File(apkPath);
      createApk(destFile);
    } catch (Exception e) {
      showErrorInDispatchThread(e.getMessage());
    }
    if (destFile == null) return;

    if (runZipAlign) {
      File realDestFile = new File(apkPath);
      final String message = executeZipAlign(zipAlignPath, destFile, realDestFile);
      if (message != null) {
        showErrorInDispatchThread(message);
        return;
      }
    }
    ApplicationManager.getApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                String title = AndroidBundle.message("android.export.package.wizard.title");
                if (!runZipAlign) {
                  Messages.showWarningDialog(
                      myWizard.getProject(),
                      "The zipalign tool was not found in the SDK.\n\n"
                          + "Please update to the latest SDK and re-export your application\n"
                          + "or run zipalign manually.\n\n"
                          + "Aligning applications allows Android to use application resources\n"
                          + "more efficiently.",
                      title);
                }
                Messages.showInfoMessage(
                    myWizard.getProject(),
                    AndroidBundle.message("android.export.package.success.message", apkPath),
                    title);
              }
            });
  }