Package com.android.builder.core
Class ApkInfoParser
java.lang.Object
com.android.builder.core.ApkInfoParser
Class to parse an APK with aapt to gather information
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classInformation about an APK -
Constructor Summary
ConstructorsConstructorDescriptionApkInfoParser(File aapt2File, com.android.ide.common.process.ProcessExecutor processExecutor) Constructs a new parser -
Method Summary
Modifier and TypeMethodDescriptiongetAaptOutput(File apkFile) Returns the full 'aapt2 dump badging' output for the given APK.getConfigurations(File apkFile) Returns the configurations (e.g.getLocalesFromApkContents(List<String> apkContents) Returns the locales of an apk as found in the badging information or null if no locales foundgetManifestContent(File apkFile) Computes and returns the info for an APK
-
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
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
-