Interface BaseVariant

    • Method Detail

      • getName

        @NonNull
        java.lang.String getName()
        Deprecated.
        Returns the name of the variant. Guaranteed to be unique.
      • getDescription

        @NonNull
        java.lang.String getDescription()
        Deprecated.
        Returns a description for the build variant.
      • getDirName

        @NonNull
        java.lang.String getDirName()
        Deprecated.
        Returns a subfolder name for the variant. Guaranteed to be unique. This is usually a mix of build type and flavor(s) (if applicable). For instance this could be: "debug" "debug/myflavor" "release/Flavor1Flavor2"
      • getBaseName

        @NonNull
        java.lang.String getBaseName()
        Deprecated.
        Returns the base name for the output of the variant. Guaranteed to be unique.
      • getFlavorName

        @NonNull
        java.lang.String getFlavorName()
        Deprecated.
        Returns the flavor name of the variant. This is a concatenation of all the applied flavors
        Returns:
        the name of the flavors, or an empty string if there is not flavors.
      • getOutputs

        @NonNull
        org.gradle.api.DomainObjectCollection<BaseVariantOutput> getOutputs()
        Deprecated.
        Returns the variant outputs. There should always be at least one output.
        Returns:
        a non-null list of variants.
      • getBuildType

        @NonNull
        com.android.builder.model.BuildType getBuildType()
        Deprecated.
        Returns the BuildType for this build variant.
      • getMergedFlavor

        @NonNull
        com.android.builder.model.ProductFlavor getMergedFlavor()
        Deprecated.
        Returns a ProductFlavor that represents the merging of the default config and the flavors of this build variant.
      • getJavaCompileOptions

        @NonNull
        com.android.build.gradle.api.JavaCompileOptions getJavaCompileOptions()
        Deprecated.
        Returns a JavaCompileOptions that represents the java compile settings for this build variant.
      • getProductFlavors

        @NonNull
        java.util.List<com.android.builder.model.ProductFlavor> getProductFlavors()
        Deprecated.
        Returns the list of ProductFlavor for this build variant.

        This is always non-null but could be empty.

      • getSourceSets

        @NonNull
        java.util.List<com.android.builder.model.SourceProvider> getSourceSets()
        Deprecated.
        Returns a list of sorted SourceProvider in order of ascending order, meaning, the earlier items are meant to be overridden by later items.
        Returns:
        a list of source provider
      • getSourceFolders

        @NonNull
        java.util.List<org.gradle.api.file.ConfigurableFileTree> getSourceFolders​(@NonNull
                                                                                  SourceKind folderType)
        Deprecated.
        Returns a list of FileCollection representing the source folders.

        You can replace calls to this method by using Component.getSources(), then use the Sources.getJava() and then SourceDirectories.getAll().

        Parameters:
        folderType - the type of folder to return.
        Returns:
        a list of folder + dependency as file collections.
      • getCompileConfiguration

        @NonNull
        org.gradle.api.artifacts.Configuration getCompileConfiguration()
        Deprecated.
        Returns the configuration object for the compilation
      • getAnnotationProcessorConfiguration

        @NonNull
        org.gradle.api.artifacts.Configuration getAnnotationProcessorConfiguration()
        Deprecated.
        Returns the configuration object for the annotation processor.
      • getRuntimeConfiguration

        @NonNull
        org.gradle.api.artifacts.Configuration getRuntimeConfiguration()
        Deprecated.
        Returns the configuration object for the runtime
      • getApplicationId

        @NonNull
        java.lang.String getApplicationId()
        Deprecated.
        Returns the applicationId of the variant.
      • getApplicationIdTextResource

        @NonNull
        @Deprecated
        org.gradle.api.resources.TextResource getApplicationIdTextResource()
        Deprecated.
        use ApplicationVariants#getApplicationId().
        Returns the true application Id of the variant. For feature variants, this returns the resolved application id from the application. For application variants, this is the same as getApplicationId.
      • getPreBuild

        @NonNull
        @Deprecated
        org.gradle.api.Task getPreBuild()
        Deprecated.
        Returns the pre-build anchor task
      • getPreBuildProvider

        @NonNull
        org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getPreBuildProvider()
        Deprecated.
        Returns the TaskProvider for the pre-build anchor task.

        Prefer this to getPreBuild() as it triggers eager configuration of the task.

      • getCheckManifest

        @NonNull
        @Deprecated
        org.gradle.api.Task getCheckManifest()
        Returns the check manifest task.
      • getCheckManifestProvider

        @NonNull
        org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getCheckManifestProvider()
        Deprecated.
        Returns the TaskProvider for the check manifest task.

        Prefer this to getCheckManifest() as it triggers eager configuration of the task.

      • getAidlCompile

        @Nullable
        @Deprecated
        com.android.build.gradle.tasks.AidlCompile getAidlCompile()
        Deprecated.
        Returns the AIDL compilation task.

        If aidl feature is disabled via BuildFeatures.getAidl() this will throw an exception (or return null during sync.)

      • getAidlCompileProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.AidlCompile> getAidlCompileProvider()
        Deprecated.
        Returns the TaskProvider for the AIDL compilation task.

        If aidl feature is disabled via BuildFeatures.getAidl() this will throw an exception (or return null during sync.)

        Prefer this to getAidlCompile() as it triggers eager configuration of the task.

      • getRenderscriptCompile

        @Nullable
        @Deprecated
        com.android.build.gradle.tasks.RenderscriptCompile getRenderscriptCompile()
        Returns the Renderscript compilation task.

        If renderscript feature is disabled via BuildFeatures.getRenderScript() this will throw an exception (or return null during sync.)

      • getRenderscriptCompileProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.RenderscriptCompile> getRenderscriptCompileProvider()
        Deprecated.
        Returns the TaskProvider for the Renderscript compilation task.

        Prefer this to getRenderscriptCompile() as it triggers eager configuration of the task.

        If renderscript feature is disabled via BuildFeatures.getRenderScript() this will throw an exception (or return null during sync.)

      • getMergeResourcesProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<MergeResources> getMergeResourcesProvider()
        Deprecated.
        Returns the TaskProvider for the resource merging task.

        Prefer this to getMergeResources() as it triggers eager configuration of the task.

      • getMergeAssets

        @Nullable
        @Deprecated
        com.android.build.gradle.tasks.MergeSourceSetFolders getMergeAssets()
        Deprecated.
        Returns the asset merging task.
      • getMergeAssetsProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.MergeSourceSetFolders> getMergeAssetsProvider()
        Deprecated.
        Returns the TaskProvider for the asset merging task.

        Prefer this to getMergeAssets() as it triggers eager configuration of the task.

      • getGenerateBuildConfig

        @Nullable
        @Deprecated
        com.android.build.gradle.tasks.GenerateBuildConfig getGenerateBuildConfig()
        Returns the BuildConfig generation task.
      • getGenerateBuildConfigProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.GenerateBuildConfig> getGenerateBuildConfigProvider()
        Deprecated.
        Returns the TaskProvider for the BuildConfig generation task.

        Prefer this to getGenerateBuildConfig() as it triggers eager configuration of the task.

      • getJavaCompile

        @NonNull
        @Deprecated
        org.gradle.api.tasks.compile.JavaCompile getJavaCompile()
        Deprecated.
        Returns the Java Compilation task
      • getJavaCompileProvider

        @NonNull
        org.gradle.api.tasks.TaskProvider<org.gradle.api.tasks.compile.JavaCompile> getJavaCompileProvider()
        Deprecated.
        Returns the TaskProvider for the Java Compilation task

        Prefer this to getJavaCompile() as it triggers eager configuration of the task.

      • getJavaCompiler

        @NonNull
        @Deprecated
        org.gradle.api.Task getJavaCompiler()
        Deprecated.
        Returns the Java Compiler task.
      • getCompileClasspath

        @NonNull
        org.gradle.api.file.FileCollection getCompileClasspath​(@Nullable
                                                               java.lang.Object key)
        Deprecated.
        Returns the java compilation classpath.

        The provided key allows controlling how much of the classpath is returned.

        • if null, the full classpath is returned
        • Otherwise the method returns the classpath up to the generated bytecode associated with the key
        Parameters:
        key - the key
        See Also:
        registerGeneratedBytecode(FileCollection)
      • getCompileClasspathArtifacts

        @NonNull
        org.gradle.api.artifacts.ArtifactCollection getCompileClasspathArtifacts​(@Nullable
                                                                                 java.lang.Object key)
        Deprecated.
        Returns the java compilation classpath as an ArtifactCollection

        The provided key allows controlling how much of the classpath is returned.

        • if null, the full classpath is returned
        • Otherwise the method returns the classpath up to the generated bytecode associated with the key
        Parameters:
        key - the key
        See Also:
        registerGeneratedBytecode(FileCollection)
      • getExternalNativeBuildTasks

        @NonNull
        @Deprecated
        java.util.Collection<com.android.build.gradle.tasks.ExternalNativeBuildTask> getExternalNativeBuildTasks()
        Returns the tasks for building external native projects.
      • getExternalNativeBuildProviders

        @NonNull
        java.util.Collection<org.gradle.api.tasks.TaskProvider<com.android.build.gradle.tasks.ExternalNativeBuildTask>> getExternalNativeBuildProviders()
        Deprecated.
        Returns the tasks for building external native projects.

        Prefer this to getExternalNativeBuildTasks() as it triggers eager configuration of the tasks.

      • getObfuscation

        @Nullable
        @Deprecated
        org.gradle.api.Task getObfuscation()
        Deprecated.
        This always returns null
        Returns the obfuscation task. This can be null if obfuscation is not enabled.
      • getMappingFile

        @Nullable
        @Deprecated
        java.io.File getMappingFile()
        Deprecated.
        Please use getMappingFileProvider() instead in order to avoid task configuration.
        Returns the obfuscation mapping file. This can be null if obfuscation is not enabled.
      • getMappingFileProvider

        @NonNull
        org.gradle.api.provider.Provider<org.gradle.api.file.FileCollection> getMappingFileProvider()
        Deprecated.
        Returns the provider of a file collection that contains an obfuscation mapping file. The file collection may be empty if obfuscation is not enabled.
      • getProcessJavaResources

        @NonNull
        @Deprecated
        org.gradle.api.tasks.AbstractCopyTask getProcessJavaResources()
        Returns the Java resource processing task.
      • getProcessJavaResourcesProvider

        @NonNull
        org.gradle.api.tasks.TaskProvider<org.gradle.api.tasks.AbstractCopyTask> getProcessJavaResourcesProvider()
        Deprecated.
        Returns the Java resource processing task.

        Prefer this to getProcessJavaResources() as it triggers eager configuration of the task.

      • getAssemble

        @Nullable
        @Deprecated
        org.gradle.api.Task getAssemble()
        Deprecated.
        Returns the assemble task for all this variant's output
      • getAssembleProvider

        @Nullable
        org.gradle.api.tasks.TaskProvider<org.gradle.api.Task> getAssembleProvider()
        Deprecated.
        Returns the TaskProvider for the assemble task.

        Prefer this to getAssemble() as it triggers eager configuration of the task.

      • addJavaSourceFoldersToModel

        void addJavaSourceFoldersToModel​(@NonNull
                                         java.io.File... sourceFolders)
        Deprecated.
        Adds new Java source folders to the model. These source folders will not be used for the default build system, but will be passed along the default Java source folders to whoever queries the model.
        Parameters:
        sourceFolders - the source folders where the generated source code is.
      • addJavaSourceFoldersToModel

        void addJavaSourceFoldersToModel​(@NonNull
                                         java.util.Collection<java.io.File> sourceFolders)
        Deprecated.
        Adds new Java source folders to the model. These source folders will not be used for the default build system, but will be passed along the default Java source folders to whoever queries the model.
        Parameters:
        sourceFolders - the source folders where the generated source code is.
      • registerJavaGeneratingTask

        @Deprecated
        void registerJavaGeneratingTask​(@NonNull
                                        org.gradle.api.Task task,
                                        @NonNull
                                        java.io.File... sourceFolders)
        Adds to the variant a task that generates Java source code.

        This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

        The new source folders are also added to the model.

        N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

        Parameters:
        task - the task
        sourceFolders - the source folders where the generated source code is.
      • registerJavaGeneratingTask

        @Deprecated
        void registerJavaGeneratingTask​(@NonNull
                                        org.gradle.api.Task task,
                                        @NonNull
                                        java.util.Collection<java.io.File> sourceFolders)
        Deprecated.
        Use #registerJavaGeneratingTask(TaskProvider, Collection)
        Adds to the variant a task that generates Java source code.

        This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

        The new source folders are also added to the model.

        N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

        Parameters:
        task - the task
        sourceFolders - the source folders where the generated source code is.
      • registerJavaGeneratingTask

        void registerJavaGeneratingTask​(@NonNull
                                        org.gradle.api.tasks.TaskProvider<? extends org.gradle.api.Task> taskProvider,
                                        @NonNull
                                        java.io.File... sourceFolders)
        Deprecated.
        Adds to the variant a task that generates Java source code.

        This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

        The new source folders are also added to the model.

        N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

        Parameters:
        taskProvider - the task provider
        sourceFolders - the source folders where the generated source code is.
      • registerJavaGeneratingTask

        void registerJavaGeneratingTask​(@NonNull
                                        org.gradle.api.tasks.TaskProvider<? extends org.gradle.api.Task> taskProvider,
                                        @NonNull
                                        java.util.Collection<java.io.File> sourceFolders)
        Deprecated.
        Adds to the variant a task that generates Java source code.

        This will make the generate[Variant]Sources task depend on this task and add the new source folders as compilation inputs.

        The new source folders are also added to the model.

        N.B. This method also supports adding generated Kotlin sources, but this behavior may change in the future. Future versions of AGP or Kotlin Gradle plugin may not support this.

        Parameters:
        taskProvider - the task provider
        sourceFolders - the source folders where the generated source code is.
      • registerExternalAptJavaOutput

        void registerExternalAptJavaOutput​(@NonNull
                                           org.gradle.api.file.ConfigurableFileTree folder)
        Deprecated.
        Register the output of an external annotation processor.

        The output is passed to the javac task, but the source generation hooks does not depend on this.

        In order to properly wire up tasks, the FileTree object must include dependency information about the task that generates the content of this folders.

        Parameters:
        folder - a ConfigurableFileTree that contains a single folder and the task dependency information
      • registerGeneratedResFolders

        void registerGeneratedResFolders​(@NonNull
                                         org.gradle.api.file.FileCollection folders)
        Deprecated.
        Adds to the variant new generated resource folders.

        In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of this folders.

        Parameters:
        folders - a FileCollection that contains the folders and the task dependency information
      • registerResGeneratingTask

        @Deprecated
        void registerResGeneratingTask​(@NonNull
                                       org.gradle.api.Task task,
                                       @NonNull
                                       java.io.File... resFolders)
        Adds to the variant a task that generates Resources. This will make the generate[Variant]Resources task depend on this task and add the new Resource folders as Resource merge inputs. The Resource folders are also added to the model.
        Parameters:
        task - the task
        resFolders - the folders where the generated resources are.
      • registerResGeneratingTask

        @Deprecated
        void registerResGeneratingTask​(@NonNull
                                       org.gradle.api.Task task,
                                       @NonNull
                                       java.util.Collection<java.io.File> resFolders)
        Adds to the variant a task that generates Resources. This will make the generate[Variant]Resources task depend on this task and add the new Resource folders as Resource merge inputs. The Resource folders are also added to the model.
        Parameters:
        task - the task
        resFolders - the folders where the generated resources are.
      • registerPreJavacGeneratedBytecode

        java.lang.Object registerPreJavacGeneratedBytecode​(@NonNull
                                                           org.gradle.api.file.FileCollection fileCollection)
        Deprecated.
        Adds to the variant new generated Java byte-code.

        This bytecode is passed to the javac classpath. This is typically used by compilers for languages that generate bytecode ahead of javac.

        The file collection can contain either a folder of class files or jars.

        In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of these folders. This is generally setup using ConfigurableFileCollection.builtBy(Object...)

        The generated byte-code will also be added to the transform pipeline as a QualifiedContent.Scope.PROJECT stream.

        The method returns a key that can be used to query for the compilation classpath. This allows each successive call to registerPreJavacGeneratedBytecode(FileCollection) to be associated with a classpath containing everything before the added bytecode.

        Parameters:
        fileCollection - a FileCollection that contains the files and the task dependency information
        Returns:
        a key for calls to registerGeneratedBytecode(FileCollection)
      • registerPostJavacGeneratedBytecode

        void registerPostJavacGeneratedBytecode​(@NonNull
                                                org.gradle.api.file.FileCollection fileCollection)
        Deprecated.
        Adds to the variant new generated Java byte-code.

        This bytecode is meant to be post javac, which means javac does not have it on its classpath. It's is only added to the java compilation task's classpath and will be added to the transform pipeline as a QualifiedContent.Scope.PROJECT stream.

        The file collection can contain either a folder of class files or jars.

        In order to properly wire up tasks, the FileCollection object must include dependency information about the task that generates the content of these folders. This is generally setup using ConfigurableFileCollection.builtBy(Object...)

        Parameters:
        fileCollection - a FileCollection that contains the files and the task dependency information
      • buildConfigField

        void buildConfigField​(@NonNull
                              java.lang.String type,
                              @NonNull
                              java.lang.String name,
                              @NonNull
                              java.lang.String value)
        Deprecated.
        Adds a variant-specific BuildConfig field.
        Parameters:
        type - the type of the field
        name - the name of the field
        value - the value of the field
      • resValue

        void resValue​(@NonNull
                      java.lang.String type,
                      @NonNull
                      java.lang.String name,
                      @NonNull
                      java.lang.String value)
        Deprecated.
        Adds a variant-specific res value.
        Parameters:
        type - the type of the field
        name - the name of the field
        value - the value of the field
      • missingDimensionStrategy

        void missingDimensionStrategy​(@NonNull
                                      java.lang.String dimension,
                                      @NonNull
                                      java.lang.String requestedValue)
        Deprecated.
        Set up a new matching request for a given flavor dimension and value.

        To learn more, read Select default flavors for missing dimensions.

        Parameters:
        dimension - the flavor dimension
        requestedValue - the flavor name
      • missingDimensionStrategy

        void missingDimensionStrategy​(@NonNull
                                      java.lang.String dimension,
                                      @NonNull
                                      java.lang.String... requestedValues)
        Deprecated.
        Set up a new matching request for a given flavor dimension and value.

        To learn more, read Select default flavors for missing dimensions.

        Parameters:
        dimension - the flavor dimension
        requestedValues - the flavor name and fallbacks
      • missingDimensionStrategy

        void missingDimensionStrategy​(@NonNull
                                      java.lang.String dimension,
                                      @NonNull
                                      java.util.List<java.lang.String> requestedValues)
        Deprecated.
        Set up a new matching request for a given flavor dimension and value.

        To learn more, read Select default flavors for missing dimensions.

        Parameters:
        dimension - the flavor dimension
        requestedValues - the flavor name and fallbacks
      • setOutputsAreSigned

        void setOutputsAreSigned​(boolean isSigned)
        Deprecated.
        If true, variant outputs will be considered signed. Only set if you manually set the outputs to point to signed files built by other tasks.
      • getAllRawAndroidResources

        @Incubating
        @NonNull
        org.gradle.api.file.FileCollection getAllRawAndroidResources()
        Deprecated.
        Returns file collection containing all raw Android resources, including the ones from transitive dependencies.

        This is an incubating API, and it can be changed or removed without notice.

      • register

        @Incubating
        void register​(org.gradle.api.Task task)
        Deprecated.
        Registers a task to be executed before any main output tasks like the assemble or bundle tasks are invoked.

        The task will need to set up its dependencies on the build outputs (whether it is an intermediate output or the final one) independently of this call.