Interface AndroidProject


public interface AndroidProject
Entry point for the model of the Android Projects. This models a single module, whether the module is an app project, a library project, a Instant App feature project, an instantApp bundle project, or a dynamic feature split project.
  • Field Details

    • PROPERTY_BUILD_MODEL_ONLY

      static final String PROPERTY_BUILD_MODEL_ONLY
      See Also:
    • PROPERTY_BUILD_MODEL_ONLY_ADVANCED

      static final String PROPERTY_BUILD_MODEL_ONLY_ADVANCED
      See Also:
    • PROPERTY_BUILD_MODEL_ONLY_VERSIONED

      static final String PROPERTY_BUILD_MODEL_ONLY_VERSIONED
      See Also:
    • PROPERTY_BUILD_MODEL_FEATURE_FULL_DEPENDENCIES

      static final String PROPERTY_BUILD_MODEL_FEATURE_FULL_DEPENDENCIES
      See Also:
    • PROPERTY_BUILD_MODEL_DISABLE_SRC_DOWNLOAD

      @Deprecated static final String PROPERTY_BUILD_MODEL_DISABLE_SRC_DOWNLOAD
      Deprecated.
      Only has effect in AGP 3.5. Android Studio 3.6 onwards downloads sources using an injected gradle tooling model and model builder.
      Was a property to disable source download during model sync, which is no longer done by AGP.
      See Also:
    • PROPERTY_ANDROID_SUPPORT_VERSION

      static final String PROPERTY_ANDROID_SUPPORT_VERSION
      See Also:
    • PROPERTY_ANDROID_STUDIO_VERSION

      static final String PROPERTY_ANDROID_STUDIO_VERSION
      See Also:
    • PROPERTY_GENERATE_SOURCES_ONLY

      static final String PROPERTY_GENERATE_SOURCES_ONLY
      See Also:
    • PROPERTY_AVOID_TASK_REGISTRATION

      static final String PROPERTY_AVOID_TASK_REGISTRATION
      Used to ask AGP to avoid task registration (if possible) during sync, in order to improve sync performance. See http://b/303832930 for details.
      See Also:
    • ARTIFACT_MAIN

      static final String ARTIFACT_MAIN
      See Also:
    • ARTIFACT_ANDROID_TEST

      static final String ARTIFACT_ANDROID_TEST
      See Also:
    • ARTIFACT_UNIT_TEST

      static final String ARTIFACT_UNIT_TEST
      See Also:
    • ARTIFACT_TEST_FIXTURES

      static final String ARTIFACT_TEST_FIXTURES
      See Also:
    • GENERATION_ORIGINAL

      static final int GENERATION_ORIGINAL
      See Also:
    • GENERATION_COMPONENT

      static final int GENERATION_COMPONENT
      See Also:
    • MODEL_LEVEL_0_ORIGINAL

      static final int MODEL_LEVEL_0_ORIGINAL
      See Also:
    • MODEL_LEVEL_1_SYNC_ISSUE

      static final int MODEL_LEVEL_1_SYNC_ISSUE
      See Also:
    • MODEL_LEVEL_3_VARIANT_OUTPUT_POST_BUILD

      static final int MODEL_LEVEL_3_VARIANT_OUTPUT_POST_BUILD
      See Also:
    • MODEL_LEVEL_4_NEW_DEP_MODEL

      static final int MODEL_LEVEL_4_NEW_DEP_MODEL
      See Also:
    • MODEL_LEVEL_LATEST

      static final int MODEL_LEVEL_LATEST
      See Also:
  • Method Details

    • getModelVersion

      @NonNull String getModelVersion()
      Returns the model version. This is a string in the format X.Y.Z
      Returns:
      a string containing the model version.
    • getApiVersion

      int getApiVersion()
      Returns the model api version.

      This is different from getModelVersion() in a way that new model version might increment model version but keep existing api. That means that code which was built against particular 'api version' might be safely re-used for all new model versions as long as they don't change the api.

      Every new model version is assumed to return an 'api version' value which is equal or greater than the value used by the previous model version.

      Returns:
      model's api version
    • getName

      @NonNull String getName()
      Returns the name of the module.
      Returns:
      the name of the module.
    • isLibrary

      @Deprecated boolean isLibrary()
      Deprecated.
      use getProjectType() instead.
      Returns whether this is a library.
      Returns:
      true for a library module.
    • getProjectType

      int getProjectType()
      Returns the type of project: Android application, library, feature, instantApp.
      Returns:
      the type of project.
      Since:
      2.3
    • getGroupId

      @Nullable String getGroupId()
      Returns the optional group-id of the artifact represented by this project.
      Since:
      3.6
    • getNamespace

      @NonNull String getNamespace()
      Returns the namespace of the main artifact.

      This is here rather than on AndroidArtifact because this is common to all artifacts as it cannot be changed per variants.

    • getAndroidTestNamespace

      @Nullable String getAndroidTestNamespace()
      Returns the namespace of the AndroidTest artifact.

      This is here rather than on AndroidArtifact because this is common to all artifacts as it cannot be changed per variants.

      If there are no AndroidTest components, this returns null.

    • getDefaultConfig

      @NonNull ProductFlavorContainer getDefaultConfig()
      Returns the ProductFlavorContainer for the 'main' default config.
      Returns:
      the product flavor.
    • getBuildTypes

      @NonNull Collection<BuildTypeContainer> getBuildTypes()
      Returns a list of all the BuildType in their container.
      Returns:
      a list of build type containers.
    • getProductFlavors

      @NonNull Collection<ProductFlavorContainer> getProductFlavors()
      Returns a list of all the ProductFlavor in their container.
      Returns:
      a list of product flavor containers.
    • getVariants

      @NonNull Collection<Variant> getVariants()
      Returns a list of all the variants. This does not include test variant. Test variants are additional artifacts in their respective variant info.
      Returns:
      a list of the variants.
    • getVariantNames

      @NonNull Collection<String> getVariantNames()
      Returns a list of all the variant names.

      This does not include test variant. Test variants are additional artifacts in their respective variant info.

      Returns:
      a list of all the variant names.
      Since:
      3.2.
    • getDefaultVariant

      @Nullable String getDefaultVariant()
      Returns the name of the variant the IDE should use when opening the project for the first time.
      Returns:
      the name of a variant that exists under the presence of the variant filter. Only returns null if all variants are removed.
      Since:
      3.5
    • getFlavorDimensions

      @NonNull Collection<String> getFlavorDimensions()
      Returns a list of all the flavor dimensions, may be empty.
      Returns:
      a list of the flavor dimensions.
    • getExtraArtifacts

      @NonNull Collection<ArtifactMetaData> getExtraArtifacts()
      Returns a list of extra artifacts meta data. This does not include the main artifact.
      Returns:
      a list of extra artifacts
    • getCompileTarget

      @NonNull String getCompileTarget()
      Returns the compilation target as a string. This is the full extended target hash string. (see com.android.sdklib.IAndroidTarget#hashString())
      Returns:
      the target hash string
    • getBootClasspath

      @NonNull Collection<String> getBootClasspath()
      Returns the boot classpath matching the compile target. This is typically android.jar plus other optional libraries.
      Returns:
      a list of jar files.
    • getFrameworkSources

      @NonNull Collection<File> getFrameworkSources()
      Returns a list of folders or jar files that contains the framework source code.
    • getNativeToolchains

      @NonNull Collection<NativeToolchain> getNativeToolchains()
      Returns the collection of toolchains used to create any native libraries.
      Returns:
      collection of toolchains.
    • getSigningConfigs

      @NonNull Collection<com.android.builder.model.SigningConfig> getSigningConfigs()
      Returns a list of SigningConfig.
    • getAaptOptions

      @NonNull AaptOptions getAaptOptions()
      Returns the aapt options.
    • getLintOptions

      @NonNull com.android.builder.model.LintOptions getLintOptions()
      Returns the lint options.
    • getUnresolvedDependencies

      @Deprecated @NonNull Collection<String> getUnresolvedDependencies()
      Deprecated.
      Returns the dependencies that were not successfully resolved. The returned list gets populated only if the system property PROPERTY_BUILD_MODEL_ONLY has been set to true.

      Each value of the collection has the format group:name:version, for example: com.google.guava:guava:15.0.2

      Returns:
      the dependencies that were not successfully resolved.
    • getSyncIssues

      @Deprecated @NonNull Collection<com.android.builder.model.SyncIssue> getSyncIssues()
      Deprecated.
      request ProjectSyncIssues instead.
      Returns issues found during sync. The returned list gets populated only if the system property PROPERTY_BUILD_MODEL_ONLY has been set to true.
    • getJavaCompileOptions

      @NonNull JavaCompileOptions getJavaCompileOptions()
      Returns the compile options for Java code.
    • getBuildFolder

      @NonNull File getBuildFolder()
      Returns the build folder of this project.
    • getResourcePrefix

      @Nullable String getResourcePrefix()
      Returns the resource prefix to use, if any. This is an optional prefix which can be set and which is used by the defaults to automatically choose new resources with a certain prefix, warn if resources are not using the given prefix, etc. This helps work with resources in the app namespace where there could otherwise be unintentional duplicated resource names between unrelated libraries.
      Returns:
      the optional resource prefix, or null if not set
    • getBuildToolsVersion

      @NonNull String getBuildToolsVersion()
      Returns the build tools version used by this module.
      Returns:
      the build tools version.
    • getNdkVersion

      @Nullable String getNdkVersion()
      Returns the NDK version used by this module.
      Returns:
      the NDK version.
    • getPluginGeneration

      int getPluginGeneration()
      Returns the generation of the plugin.

      1 is original plugin, 2 is component based plugin (AKA experimental, not used anymore)

      Returns:
      the generation value
    • isBaseSplit

      boolean isBaseSplit()
      Returns true if this is the base feature split.
      Returns:
      true if this is the base feature split
      Since:
      2.4
    • getDynamicFeatures

      @NonNull Collection<String> getDynamicFeatures()
      Returns the list of dynamic features.

      The values are Gradle path. Only valid for base splits.

      Returns:
    • getViewBindingOptions

      @NonNull ViewBindingOptions getViewBindingOptions()
      Returns the options for view binding.
    • getDependenciesInfo

      @Nullable com.android.builder.model.DependenciesInfo getDependenciesInfo()
    • getFlags

      @NonNull AndroidGradlePluginProjectFlags getFlags()
      Returns the AGP flags for this project.
    • getVariantsBuildInformation

      @NonNull Collection<com.android.builder.model.VariantBuildInformation> getVariantsBuildInformation()
      Returns the minimal information of variants for this project, excluding test related variants.
      Since:
      4.1
    • getLintRuleJars

      @NonNull List<File> getLintRuleJars()
      Returns the lint jars that this module uses to run extra lint checks