com.android.builder.core
Class AndroidBuilder

java.lang.Object
  extended by com.android.builder.core.AndroidBuilder

public class AndroidBuilder
extends java.lang.Object

This is the main builder class. It is given all the data to process the build (such as DefaultProductFlavors, DefaultBuildType and dependencies) and use them when doing specific build steps. To use: create a builder with #AndroidBuilder(String, CommandLineRunner, ProcessExecutor, JavaProcessExecutor, ProcessOutputHandler, ILogger, boolean) then build steps can be done with mergeManifests(File, List, List, String, int, String, String, String, Integer, String, String, ManifestMerger2.MergeType, Map, File) processTestManifest(String, String, String, String, String, Boolean, Boolean, File, List, Map, File, File) processResources(AaptPackageProcessBuilder, boolean) compileAllAidlFiles(java.util.List, java.io.File, java.io.File, java.util.List, com.android.builder.compiling.DependencyFileProcessor) #convertByteCode(Collection, Collection, File, boolean, boolean, File, DexOptions, List, File, boolean, boolean) #packageApk(String, java.io.File, java.util.Collection, java.util.Collection, String, java.util.Collection, java.util.Set, boolean, com.android.builder.model.SigningConfig, com.android.builder.model.PackagingOptions, String) Java compilation is not handled but the builder provides the bootclasspath with getBootClasspath().


Constructor Summary
AndroidBuilder(java.lang.String projectId, java.lang.String createdBy, com.android.ide.common.process.ProcessExecutor processExecutor, com.android.ide.common.process.JavaProcessExecutor javaProcessExecutor, com.android.ide.common.process.ProcessOutputHandler processOutputHandler, EvaluationErrorReporter errorHandler, com.android.utils.ILogger logger, boolean verboseExec)
          Creates an AndroidBuilder.
 
Method Summary
 void compileAidlFile(java.io.File sourceFolder, java.io.File aidlFile, java.io.File sourceOutputDir, java.io.File parcelableOutputDir, java.util.List<java.io.File> importFolders, DependencyFileProcessor dependencyFileProcessor)
          Compiles the given aidl file.
 void compileAllAidlFiles(java.util.List<java.io.File> sourceFolders, java.io.File sourceOutputDir, java.io.File parcelableOutputDir, java.util.List<java.io.File> importFolders, DependencyFileProcessor dependencyFileProcessor)
          Compiles all the aidl files found in the given source folders.
 void compileAllRenderscriptFiles(java.util.List<java.io.File> sourceFolders, java.util.List<java.io.File> importFolders, java.io.File sourceOutputDir, java.io.File resOutputDir, java.io.File objOutputDir, java.io.File libOutputDir, int targetApi, boolean debugBuild, int optimLevel, boolean ndkMode, boolean supportMode, java.util.Set<java.lang.String> abiFilters)
          Compiles all the renderscript files found in the given source folders.
 void convertByteCode(java.util.Collection<java.io.File> inputs, java.util.Collection<java.io.File> preDexedLibraries, java.io.File outDexFolder, boolean multidex, java.io.File mainDexList, DexOptions dexOptions, java.util.List<java.lang.String> additionalParameters, java.io.File tmpFolder, boolean incremental, boolean optimize)
          Converts the bytecode to Dalvik format
 boolean convertByteCodeUsingJackApis(java.io.File dexOutputFolder, java.io.File jackOutputFile, java.util.Collection<java.io.File> classpath, java.util.Collection<java.io.File> packagedLibraries, java.util.Collection<java.io.File> sourceFiles, java.util.Collection<java.io.File> proguardFiles, java.io.File mappingFile, java.util.Collection<java.io.File> jarJarRulesFiles, java.io.File incrementalDir, boolean multiDex, int minSdkVersion)
          Converts java source code into android byte codes using the jack integration APIs.
 void convertByteCodeWithJack(java.io.File dexOutputFolder, java.io.File jackOutputFile, java.lang.String classpath, java.util.Collection<java.io.File> packagedLibraries, java.io.File ecjOptionFile, java.util.Collection<java.io.File> proguardFiles, java.io.File mappingFile, java.util.Collection<java.io.File> jarJarRuleFiles, boolean multiDex, int minSdkVersion, boolean debugLog, java.lang.String javaMaxHeapSize)
           
static java.util.List<java.io.File> convertLibaryToJackUsingApis(java.io.File inputFile, java.io.File outFile, DexOptions dexOptions, com.android.sdklib.BuildToolInfo buildToolInfo, boolean verbose, com.android.ide.common.process.JavaProcessExecutor processExecutor, com.android.ide.common.process.ProcessOutputHandler processOutputHandler, com.android.utils.ILogger logger)
           
 void convertLibraryToJack(java.io.File inputFile, java.io.File outFile, DexOptions dexOptions)
          Converts the bytecode of a library to the jack format
static java.util.List<java.io.File> convertLibraryToJack(java.io.File inputFile, java.io.File outFile, DexOptions dexOptions, com.android.sdklib.BuildToolInfo buildToolInfo, boolean verbose, com.android.ide.common.process.JavaProcessExecutor processExecutor, com.android.ide.common.process.ProcessOutputHandler processOutputHandler, com.android.utils.ILogger logger)
           
static com.android.builder.model.ClassField createClassField(java.lang.String type, java.lang.String name, java.lang.String value)
           
 java.util.Set<java.lang.String> createMainDexList(java.io.File allClassesJarFile, java.io.File jarOfRoots)
           
 com.android.ide.common.process.ProcessResult executeProcess(com.android.ide.common.process.ProcessInfo processInfo)
           
 com.android.ide.common.process.ProcessResult executeProcess(com.android.ide.common.process.ProcessInfo processInfo, com.android.ide.common.process.ProcessOutputHandler handler)
           
 void generateApkData(java.io.File apkFile, java.io.File outResFolder, java.lang.String mainPkgName, java.lang.String resName)
           
static void generateApkDataEntryInManifest(int minSdkVersion, int targetSdkVersion, java.io.File manifestFile)
           
 com.android.ide.common.internal.PngCruncher getAaptCruncher()
          Returns an PngCruncher using aapt underneath
 java.util.List<java.io.File> getBootClasspath()
          Helper method to get the boot classpath to be used during compilation.
 java.util.List<java.lang.String> getBootClasspathAsStrings()
          Helper method to get the boot classpath to be used during compilation.
 java.util.Set<java.io.File> getCompileClasspath(VariantConfiguration<?,?,?> variantConfiguration)
          Returns the compile classpath for this config.
 java.io.File getDxJar()
           
 java.util.List<java.io.File> getLeafFolders(java.lang.String extension, java.util.List<java.io.File>... importFolders)
          Computes and returns the leaf folders based on a given file extension.
 com.android.utils.ILogger getLogger()
           
 java.util.Set<java.io.File> getPackagedJars(VariantConfiguration<?,?,?> variantConfiguration)
          Returns the list of packaged jars for this config.
 com.android.ide.common.process.ProcessExecutor getProcessExecutor()
           
 java.io.File getRenderScriptSupportJar()
          Returns the jar file for the renderscript mode.
 SdkInfo getSdkInfo()
          Returns the SdkInfo, if set.
 java.io.File getSupportNativeLibFolder()
          Returns the native lib folder for the renderscript mode.
 com.android.sdklib.IAndroidTarget getTarget()
          Returns the compilation target, if set.
 java.lang.String getTargetCodename()
           
 TargetInfo getTargetInfo()
          Returns the TargetInfo, if set.
 boolean isPreviewTarget()
          Returns whether the compilation target is a preview.
 void mergeManifests(java.io.File mainManifest, java.util.List<java.io.File> manifestOverlays, java.util.List<? extends ManifestDependency> libraries, java.lang.String packageOverride, int versionCode, java.lang.String versionName, java.lang.String minSdkVersion, java.lang.String targetSdkVersion, java.lang.Integer maxSdkVersion, java.lang.String outManifestLocation, java.lang.String outAaptSafeManifestLocation, com.android.manifmerger.ManifestMerger2.MergeType mergeType, java.util.Map<java.lang.String,java.lang.String> placeHolders, java.io.File reportFile)
          Invoke the Manifest Merger version 2.
 void packageApk(java.lang.String androidResPkgLocation, java.io.File dexFolder, java.util.Collection<java.io.File> dexedLibraries, java.util.Collection<java.io.File> packagedJars, java.lang.String javaResourcesLocation, java.util.Collection<java.io.File> jniLibsFolders, java.io.File mergingFolder, java.util.Set<java.lang.String> abiFilters, boolean jniDebugBuild, com.android.builder.model.SigningConfig signingConfig, com.android.builder.model.PackagingOptions packagingOptions, java.lang.String outApkLocation)
          Packages the apk.
 void preDexLibrary(java.io.File inputFile, java.io.File outFile, boolean multiDex, DexOptions dexOptions)
          Converts the bytecode to Dalvik format
static com.google.common.collect.ImmutableList<java.io.File> preDexLibrary(java.io.File inputFile, java.io.File outFile, boolean multiDex, DexOptions dexOptions, com.android.sdklib.BuildToolInfo buildToolInfo, boolean verbose, com.android.ide.common.process.JavaProcessExecutor processExecutor, com.android.ide.common.process.ProcessOutputHandler processOutputHandler)
          Converts the bytecode to Dalvik format
 void processResources(AaptPackageProcessBuilder aaptCommand, boolean enforceUniquePackageName)
          Process the resources and generate R.java and/or the packaged resources.
 void processTestManifest(java.lang.String testApplicationId, java.lang.String minSdkVersion, java.lang.String targetSdkVersion, java.lang.String testedApplicationId, java.lang.String instrumentationRunner, java.lang.Boolean handleProfiling, java.lang.Boolean functionalTest, java.io.File testManifestFile, java.util.List<? extends ManifestDependency> libraries, java.util.Map<java.lang.String,java.lang.Object> manifestPlaceholders, java.io.File outManifest, java.io.File tmpDir)
          Creates the manifest for a test variant
 void setTargetInfo(SdkInfo sdkInfo, TargetInfo targetInfo, java.util.Collection<LibraryRequest> libraryRequests)
          Sets the SdkInfo and the targetInfo on the builder.
 void signApk(java.io.File in, com.android.builder.model.SigningConfig signingConfig, java.io.File out)
          Signs a single jar file using the passed SigningConfig.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidBuilder

public AndroidBuilder(@NonNull
                      java.lang.String projectId,
                      @Nullable
                      java.lang.String createdBy,
                      @NonNull
                      com.android.ide.common.process.ProcessExecutor processExecutor,
                      @NonNull
                      com.android.ide.common.process.JavaProcessExecutor javaProcessExecutor,
                      @NonNull
                      com.android.ide.common.process.ProcessOutputHandler processOutputHandler,
                      @NonNull
                      EvaluationErrorReporter errorHandler,
                      @NonNull
                      com.android.utils.ILogger logger,
                      boolean verboseExec)
Creates an AndroidBuilder.

verboseExec is needed on top of the ILogger due to remote exec tools not being able to output info and verbose messages separately.

Parameters:
createdBy - the createdBy String for the apk manifest.
logger - the Logger
verboseExec - whether external tools are launched in verbose mode
Method Detail

setTargetInfo

public void setTargetInfo(@NonNull
                          SdkInfo sdkInfo,
                          @NonNull
                          TargetInfo targetInfo,
                          @NonNull
                          java.util.Collection<LibraryRequest> libraryRequests)
Sets the SdkInfo and the targetInfo on the builder. This is required to actually build (some of the steps).

Parameters:
sdkInfo - the SdkInfo
targetInfo - the TargetInfo
See Also:
SdkLoader

getSdkInfo

@Nullable
public SdkInfo getSdkInfo()
Returns the SdkInfo, if set.


getTargetInfo

@Nullable
public TargetInfo getTargetInfo()
Returns the TargetInfo, if set.


getLogger

@NonNull
public com.android.utils.ILogger getLogger()

getTarget

@Nullable
public com.android.sdklib.IAndroidTarget getTarget()
Returns the compilation target, if set.


isPreviewTarget

public boolean isPreviewTarget()
Returns whether the compilation target is a preview.


getTargetCodename

public java.lang.String getTargetCodename()

getDxJar

@NonNull
public java.io.File getDxJar()

getBootClasspath

@NonNull
public java.util.List<java.io.File> getBootClasspath()
Helper method to get the boot classpath to be used during compilation.


getBootClasspathAsStrings

@NonNull
public java.util.List<java.lang.String> getBootClasspathAsStrings()
Helper method to get the boot classpath to be used during compilation.


getRenderScriptSupportJar

@Nullable
public java.io.File getRenderScriptSupportJar()
Returns the jar file for the renderscript mode. This may return null if the SDK has not been loaded yet.

Returns:
the jar file, or null.
See Also:
setTargetInfo(SdkInfo, TargetInfo, Collection)

getCompileClasspath

@NonNull
public java.util.Set<java.io.File> getCompileClasspath(@NonNull
                                                               VariantConfiguration<?,?,?> variantConfiguration)
Returns the compile classpath for this config. If the config tests a library, this will include the classpath of the tested config. If the SDK was loaded, this may include the renderscript support jar.

Returns:
a non null, but possibly empty set.

getPackagedJars

@NonNull
public java.util.Set<java.io.File> getPackagedJars(@NonNull
                                                           VariantConfiguration<?,?,?> variantConfiguration)
Returns the list of packaged jars for this config. If the config tests a library, this will include the jars of the tested config If the SDK was loaded, this may include the renderscript support jar.

Returns:
a non null, but possibly empty list.

getSupportNativeLibFolder

@Nullable
public java.io.File getSupportNativeLibFolder()
Returns the native lib folder for the renderscript mode. This may return null if the SDK has not been loaded yet.

Returns:
the folder, or null.
See Also:
setTargetInfo(SdkInfo, TargetInfo, Collection)

getAaptCruncher

@NonNull
public com.android.ide.common.internal.PngCruncher getAaptCruncher()
Returns an PngCruncher using aapt underneath

Returns:
an PngCruncher object

getProcessExecutor

@NonNull
public com.android.ide.common.process.ProcessExecutor getProcessExecutor()

executeProcess

@NonNull
public com.android.ide.common.process.ProcessResult executeProcess(@NonNull
                                                                           com.android.ide.common.process.ProcessInfo processInfo)

executeProcess

@NonNull
public com.android.ide.common.process.ProcessResult executeProcess(@NonNull
                                                                           com.android.ide.common.process.ProcessInfo processInfo,
                                                                           @NonNull
                                                                           com.android.ide.common.process.ProcessOutputHandler handler)

createClassField

@NonNull
public static com.android.builder.model.ClassField createClassField(@NonNull
                                                                            java.lang.String type,
                                                                            @NonNull
                                                                            java.lang.String name,
                                                                            @NonNull
                                                                            java.lang.String value)

mergeManifests

public void mergeManifests(@NonNull
                           java.io.File mainManifest,
                           @NonNull
                           java.util.List<java.io.File> manifestOverlays,
                           @NonNull
                           java.util.List<? extends ManifestDependency> libraries,
                           java.lang.String packageOverride,
                           int versionCode,
                           java.lang.String versionName,
                           @Nullable
                           java.lang.String minSdkVersion,
                           @Nullable
                           java.lang.String targetSdkVersion,
                           @Nullable
                           java.lang.Integer maxSdkVersion,
                           @NonNull
                           java.lang.String outManifestLocation,
                           @Nullable
                           java.lang.String outAaptSafeManifestLocation,
                           com.android.manifmerger.ManifestMerger2.MergeType mergeType,
                           java.util.Map<java.lang.String,java.lang.String> placeHolders,
                           @Nullable
                           java.io.File reportFile)
Invoke the Manifest Merger version 2.


processTestManifest

public void processTestManifest(@NonNull
                                java.lang.String testApplicationId,
                                @Nullable
                                java.lang.String minSdkVersion,
                                @Nullable
                                java.lang.String targetSdkVersion,
                                @NonNull
                                java.lang.String testedApplicationId,
                                @NonNull
                                java.lang.String instrumentationRunner,
                                @NonNull
                                java.lang.Boolean handleProfiling,
                                @NonNull
                                java.lang.Boolean functionalTest,
                                @Nullable
                                java.io.File testManifestFile,
                                @NonNull
                                java.util.List<? extends ManifestDependency> libraries,
                                @NonNull
                                java.util.Map<java.lang.String,java.lang.Object> manifestPlaceholders,
                                @NonNull
                                java.io.File outManifest,
                                @NonNull
                                java.io.File tmpDir)
Creates the manifest for a test variant

Parameters:
testApplicationId - the application id of the test application
minSdkVersion - the minSdkVersion of the test application
targetSdkVersion - the targetSdkVersion of the test application
testedApplicationId - the application id of the tested application
instrumentationRunner - the name of the instrumentation runner
handleProfiling - whether or not the Instrumentation object will turn profiling on and off
functionalTest - whether or not the Instrumentation class should run as a functional test
testManifestFile - optionally user provided AndroidManifest.xml for testing application
libraries - the library dependency graph
outManifest - the output location for the merged manifest
See Also:
VariantConfiguration.getApplicationId(), VariantConfiguration.getTestedConfig(), VariantConfiguration.getMinSdkVersion(), VariantConfiguration.getTestedApplicationId(), VariantConfiguration.getInstrumentationRunner(), VariantConfiguration.getHandleProfiling(), VariantConfiguration.getFunctionalTest(), VariantConfiguration.getDirectLibraries()

processResources

public void processResources(@NonNull
                             AaptPackageProcessBuilder aaptCommand,
                             boolean enforceUniquePackageName)
                      throws java.io.IOException,
                             java.lang.InterruptedException,
                             com.android.ide.common.process.ProcessException
Process the resources and generate R.java and/or the packaged resources.

Parameters:
aaptCommand - aapt command invocation parameters.
enforceUniquePackageName - if true method will fail if some libraries share the same package name
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.process.ProcessException

generateApkData

public void generateApkData(@NonNull
                            java.io.File apkFile,
                            @NonNull
                            java.io.File outResFolder,
                            @NonNull
                            java.lang.String mainPkgName,
                            @NonNull
                            java.lang.String resName)
                     throws com.android.ide.common.process.ProcessException,
                            java.io.IOException
Throws:
com.android.ide.common.process.ProcessException
java.io.IOException

generateApkDataEntryInManifest

public static void generateApkDataEntryInManifest(int minSdkVersion,
                                                  int targetSdkVersion,
                                                  @NonNull
                                                  java.io.File manifestFile)
                                           throws java.lang.InterruptedException,
                                                  com.android.ide.common.internal.LoggedErrorException,
                                                  java.io.IOException
Throws:
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
java.io.IOException

compileAllAidlFiles

public void compileAllAidlFiles(@NonNull
                                java.util.List<java.io.File> sourceFolders,
                                @NonNull
                                java.io.File sourceOutputDir,
                                @Nullable
                                java.io.File parcelableOutputDir,
                                @NonNull
                                java.util.List<java.io.File> importFolders,
                                @Nullable
                                DependencyFileProcessor dependencyFileProcessor)
                         throws java.io.IOException,
                                java.lang.InterruptedException,
                                com.android.ide.common.internal.LoggedErrorException,
                                com.android.ide.common.process.ProcessException
Compiles all the aidl files found in the given source folders.

Parameters:
sourceFolders - all the source folders to find files to compile
sourceOutputDir - the output dir in which to generate the source code
importFolders - import folders
dependencyFileProcessor - the dependencyFileProcessor to record the dependencies of the compilation.
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
com.android.ide.common.process.ProcessException

compileAidlFile

public void compileAidlFile(@NonNull
                            java.io.File sourceFolder,
                            @NonNull
                            java.io.File aidlFile,
                            @NonNull
                            java.io.File sourceOutputDir,
                            @Nullable
                            java.io.File parcelableOutputDir,
                            @NonNull
                            java.util.List<java.io.File> importFolders,
                            @Nullable
                            DependencyFileProcessor dependencyFileProcessor)
                     throws java.io.IOException,
                            java.lang.InterruptedException,
                            com.android.ide.common.internal.LoggedErrorException,
                            com.android.ide.common.process.ProcessException
Compiles the given aidl file.

Parameters:
aidlFile - the AIDL file to compile
sourceOutputDir - the output dir in which to generate the source code
importFolders - all the import folders, including the source folders.
dependencyFileProcessor - the dependencyFileProcessor to record the dependencies of the compilation.
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
com.android.ide.common.process.ProcessException

compileAllRenderscriptFiles

public void compileAllRenderscriptFiles(@NonNull
                                        java.util.List<java.io.File> sourceFolders,
                                        @NonNull
                                        java.util.List<java.io.File> importFolders,
                                        @NonNull
                                        java.io.File sourceOutputDir,
                                        @NonNull
                                        java.io.File resOutputDir,
                                        @NonNull
                                        java.io.File objOutputDir,
                                        @NonNull
                                        java.io.File libOutputDir,
                                        int targetApi,
                                        boolean debugBuild,
                                        int optimLevel,
                                        boolean ndkMode,
                                        boolean supportMode,
                                        @Nullable
                                        java.util.Set<java.lang.String> abiFilters)
                                 throws java.lang.InterruptedException,
                                        com.android.ide.common.process.ProcessException,
                                        com.android.ide.common.internal.LoggedErrorException,
                                        java.io.IOException
Compiles all the renderscript files found in the given source folders. Right now this is the only way to compile them as the renderscript compiler requires all renderscript files to be passed for all compilation. Therefore whenever a renderscript file or header changes, all must be recompiled.

Parameters:
sourceFolders - all the source folders to find files to compile
importFolders - all the import folders.
sourceOutputDir - the output dir in which to generate the source code
resOutputDir - the output dir in which to generate the bitcode file
targetApi - the target api
debugBuild - whether the build is debug
optimLevel - the optimization level
ndkMode -
supportMode - support mode flag to generate .so files.
abiFilters - ABI filters in case of support mode
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.internal.LoggedErrorException
com.android.ide.common.process.ProcessException

getLeafFolders

@NonNull
public java.util.List<java.io.File> getLeafFolders(@NonNull
                                                           java.lang.String extension,
                                                           java.util.List<java.io.File>... importFolders)
Computes and returns the leaf folders based on a given file extension. This looks through all the given root import folders, and recursively search for leaf folders containing files matching the given extensions. All the leaf folders are gathered and returned in the list.

Parameters:
extension - the extension to search for.
importFolders - an array of list of root folders.
Returns:
a list of leaf folder, never null.

convertByteCode

public void convertByteCode(@NonNull
                            java.util.Collection<java.io.File> inputs,
                            @NonNull
                            java.util.Collection<java.io.File> preDexedLibraries,
                            @NonNull
                            java.io.File outDexFolder,
                            boolean multidex,
                            @Nullable
                            java.io.File mainDexList,
                            @NonNull
                            DexOptions dexOptions,
                            @Nullable
                            java.util.List<java.lang.String> additionalParameters,
                            @NonNull
                            java.io.File tmpFolder,
                            boolean incremental,
                            boolean optimize)
                     throws java.io.IOException,
                            java.lang.InterruptedException,
                            com.android.ide.common.process.ProcessException
Converts the bytecode to Dalvik format

Parameters:
inputs - the input files
preDexedLibraries - the list of pre-dexed libraries
outDexFolder - the location of the output folder
dexOptions - dex options
additionalParameters - list of additional parameters to give to dx
incremental - true if it should attempt incremental dex if applicable
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.process.ProcessException

createMainDexList

public java.util.Set<java.lang.String> createMainDexList(@NonNull
                                                         java.io.File allClassesJarFile,
                                                         @NonNull
                                                         java.io.File jarOfRoots)
                                                  throws com.android.ide.common.process.ProcessException
Throws:
com.android.ide.common.process.ProcessException

preDexLibrary

public void preDexLibrary(@NonNull
                          java.io.File inputFile,
                          @NonNull
                          java.io.File outFile,
                          boolean multiDex,
                          @NonNull
                          DexOptions dexOptions)
                   throws java.io.IOException,
                          java.lang.InterruptedException,
                          com.android.ide.common.process.ProcessException
Converts the bytecode to Dalvik format

Parameters:
inputFile - the input file
outFile - the output file or folder if multi-dex is enabled.
multiDex - whether multidex is enabled.
dexOptions - dex options
Throws:
java.io.IOException
java.lang.InterruptedException
com.android.ide.common.process.ProcessException

preDexLibrary

@NonNull
public static com.google.common.collect.ImmutableList<java.io.File> preDexLibrary(@NonNull
                                                                                          java.io.File inputFile,
                                                                                          @NonNull
                                                                                          java.io.File outFile,
                                                                                          boolean multiDex,
                                                                                          @NonNull
                                                                                          DexOptions dexOptions,
                                                                                          @NonNull
                                                                                          com.android.sdklib.BuildToolInfo buildToolInfo,
                                                                                          boolean verbose,
                                                                                          @NonNull
                                                                                          com.android.ide.common.process.JavaProcessExecutor processExecutor,
                                                                                          @NonNull
                                                                                          com.android.ide.common.process.ProcessOutputHandler processOutputHandler)
                                                                           throws com.android.ide.common.process.ProcessException
Converts the bytecode to Dalvik format

Parameters:
inputFile - the input file
outFile - the output file or folder if multi-dex is enabled.
multiDex - whether multidex is enabled.
dexOptions - the dex options
buildToolInfo - the build tools info
verbose - verbose flag
processExecutor - the java process executor
Returns:
the list of generated files.
Throws:
com.android.ide.common.process.ProcessException

convertByteCodeUsingJackApis

public boolean convertByteCodeUsingJackApis(@NonNull
                                            java.io.File dexOutputFolder,
                                            @NonNull
                                            java.io.File jackOutputFile,
                                            @NonNull
                                            java.util.Collection<java.io.File> classpath,
                                            @NonNull
                                            java.util.Collection<java.io.File> packagedLibraries,
                                            @NonNull
                                            java.util.Collection<java.io.File> sourceFiles,
                                            @Nullable
                                            java.util.Collection<java.io.File> proguardFiles,
                                            @Nullable
                                            java.io.File mappingFile,
                                            @NonNull
                                            java.util.Collection<java.io.File> jarJarRulesFiles,
                                            @Nullable
                                            java.io.File incrementalDir,
                                            boolean multiDex,
                                            int minSdkVersion)
Converts java source code into android byte codes using the jack integration APIs. Jack will run in memory.


convertByteCodeWithJack

public void convertByteCodeWithJack(@NonNull
                                    java.io.File dexOutputFolder,
                                    @NonNull
                                    java.io.File jackOutputFile,
                                    @NonNull
                                    java.lang.String classpath,
                                    @NonNull
                                    java.util.Collection<java.io.File> packagedLibraries,
                                    @NonNull
                                    java.io.File ecjOptionFile,
                                    @Nullable
                                    java.util.Collection<java.io.File> proguardFiles,
                                    @Nullable
                                    java.io.File mappingFile,
                                    @NonNull
                                    java.util.Collection<java.io.File> jarJarRuleFiles,
                                    boolean multiDex,
                                    int minSdkVersion,
                                    boolean debugLog,
                                    java.lang.String javaMaxHeapSize)
                             throws com.android.ide.common.process.ProcessException
Throws:
com.android.ide.common.process.ProcessException

convertLibraryToJack

public void convertLibraryToJack(@NonNull
                                 java.io.File inputFile,
                                 @NonNull
                                 java.io.File outFile,
                                 @NonNull
                                 DexOptions dexOptions)
                          throws com.android.ide.common.process.ProcessException,
                                 java.io.IOException,
                                 java.lang.InterruptedException
Converts the bytecode of a library to the jack format

Parameters:
inputFile - the input file
outFile - the location of the output classes.dex file
dexOptions - dex options
Throws:
com.android.ide.common.process.ProcessException
java.io.IOException
java.lang.InterruptedException

convertLibaryToJackUsingApis

public static java.util.List<java.io.File> convertLibaryToJackUsingApis(@NonNull
                                                                        java.io.File inputFile,
                                                                        @NonNull
                                                                        java.io.File outFile,
                                                                        @NonNull
                                                                        DexOptions dexOptions,
                                                                        @NonNull
                                                                        com.android.sdklib.BuildToolInfo buildToolInfo,
                                                                        boolean verbose,
                                                                        @NonNull
                                                                        com.android.ide.common.process.JavaProcessExecutor processExecutor,
                                                                        @NonNull
                                                                        com.android.ide.common.process.ProcessOutputHandler processOutputHandler,
                                                                        @NonNull
                                                                        com.android.utils.ILogger logger)
                                                                 throws com.android.ide.common.process.ProcessException
Throws:
com.android.ide.common.process.ProcessException

convertLibraryToJack

public static java.util.List<java.io.File> convertLibraryToJack(@NonNull
                                                                java.io.File inputFile,
                                                                @NonNull
                                                                java.io.File outFile,
                                                                @NonNull
                                                                DexOptions dexOptions,
                                                                @NonNull
                                                                com.android.sdklib.BuildToolInfo buildToolInfo,
                                                                boolean verbose,
                                                                @NonNull
                                                                com.android.ide.common.process.JavaProcessExecutor processExecutor,
                                                                @NonNull
                                                                com.android.ide.common.process.ProcessOutputHandler processOutputHandler,
                                                                @NonNull
                                                                com.android.utils.ILogger logger)
                                                         throws com.android.ide.common.process.ProcessException
Throws:
com.android.ide.common.process.ProcessException

packageApk

public void packageApk(@NonNull
                       java.lang.String androidResPkgLocation,
                       @Nullable
                       java.io.File dexFolder,
                       @NonNull
                       java.util.Collection<java.io.File> dexedLibraries,
                       @NonNull
                       java.util.Collection<java.io.File> packagedJars,
                       @Nullable
                       java.lang.String javaResourcesLocation,
                       @Nullable
                       java.util.Collection<java.io.File> jniLibsFolders,
                       @NonNull
                       java.io.File mergingFolder,
                       @Nullable
                       java.util.Set<java.lang.String> abiFilters,
                       boolean jniDebugBuild,
                       @Nullable
                       com.android.builder.model.SigningConfig signingConfig,
                       @Nullable
                       com.android.builder.model.PackagingOptions packagingOptions,
                       @NonNull
                       java.lang.String outApkLocation)
                throws DuplicateFileException,
                       java.io.FileNotFoundException,
                       com.android.ide.common.signing.KeytoolException,
                       PackagerException,
                       SigningException
Packages the apk.

Parameters:
androidResPkgLocation - the location of the packaged resource file
dexFolder - the folder with the dex file.
dexedLibraries - optional collection of additional dex files to put in the apk.
packagedJars - the jars that are packaged (libraries + jar dependencies)
javaResourcesLocation - the processed Java resource folder
jniLibsFolders - the folders containing jni shared libraries
mergingFolder - folder to contain files that are being merged
abiFilters - optional ABI filter
jniDebugBuild - whether the app should include jni debug data
signingConfig - the signing configuration
packagingOptions - the packaging options
outApkLocation - location of the APK.
Throws:
DuplicateFileException
java.io.FileNotFoundException - if the store location was not found
com.android.ide.common.signing.KeytoolException
PackagerException
SigningException - when the key cannot be read from the keystore
See Also:
VariantConfiguration.getPackagedJars()

signApk

public void signApk(java.io.File in,
                    com.android.builder.model.SigningConfig signingConfig,
                    java.io.File out)
             throws java.io.IOException,
                    com.android.ide.common.signing.KeytoolException,
                    SigningException,
                    java.security.NoSuchAlgorithmException,
                    SignedJarBuilder.IZipEntryFilter.ZipAbortException,
                    SigningException
Signs a single jar file using the passed SigningConfig.

Parameters:
in - the jar file to sign.
signingConfig - the signing configuration
out - the file path for the signed jar.
Throws:
java.io.IOException
com.android.ide.common.signing.KeytoolException
SigningException
java.security.NoSuchAlgorithmException
SignedJarBuilder.IZipEntryFilter.ZipAbortException
SigningException