Class ApkInfoParser

java.lang.Object
com.android.builder.core.ApkInfoParser

public class ApkInfoParser extends Object
Class to parse an APK with aapt to gather information
  • Constructor Details

    • ApkInfoParser

      public ApkInfoParser(@NonNull File aapt2File, @NonNull com.android.ide.common.process.ProcessExecutor processExecutor)
      Constructs a new parser
      Parameters:
      aapt2File - the AAPT2 executable file or the directory containing it.
      processExecutor - a process executor to call AAPT2
  • Method Details

    • parseApk

      @NonNull public ApkInfoParser.ApkInfo parseApk(@NonNull File apkFile) throws com.android.ide.common.process.ProcessException
      Computes and returns the info for an APK
      Parameters:
      apkFile - the APK to parse
      Returns:
      a non-null ApkInfo object.
      Throws:
      com.android.ide.common.process.ProcessException - when aapt failed to execute
    • getAaptOutput

      @NonNull public List<String> getAaptOutput(@NonNull File apkFile) throws com.android.ide.common.process.ProcessException
      Returns the full 'aapt2 dump badging' output for the given APK.
      Throws:
      com.android.ide.common.process.ProcessException
    • getManifestContent

      @NonNull public List<String> getManifestContent(@NonNull File apkFile) throws com.android.ide.common.process.ProcessException
      Throws:
      com.android.ide.common.process.ProcessException
    • getConfigurations

      @NonNull public List<String> getConfigurations(@NonNull File apkFile) throws com.android.ide.common.process.ProcessException
      Returns the configurations (e.g. languages) in the APK.
      Throws:
      com.android.ide.common.process.ProcessException
    • getLocalesFromApkContents

      @Nullable public static List<String> getLocalesFromApkContents(@NonNull List<String> apkContents)
      Returns the locales of an apk as found in the badging information or null if no locales found
      Parameters:
      apkContents - the apk contents in a list of strings
      Returns:
      the list of locales or null