Class DefaultSdkLoader

java.lang.Object
com.android.builder.sdk.DefaultSdkLoader
All Implemented Interfaces:
SdkLoader

public class DefaultSdkLoader extends Object implements SdkLoader
Singleton-based implementation of SdkLoader for a standard SDK
  • Method Details

    • getLoader

      public static SdkLoader getLoader(@NonNull com.android.prefs.AndroidLocationsProvider androidLocationsProvider, @NonNull File sdkLocation)
    • unload

      public static void unload()
    • getTargetInfo

      @NonNull public TargetInfo getTargetInfo(@NonNull String targetHash, @NonNull com.android.repository.Revision buildToolRevision, @NonNull com.android.utils.ILogger logger, @NonNull SdkLibData sdkLibData) throws LicenceNotAcceptedException, InstallFailedException
      Description copied from interface: SdkLoader
      Returns information about a build target. Potentially downloads SDK components if sdkLibData.useSdlDownload() is true. This requires loading/parsing the SDK.
      Specified by:
      getTargetInfo in interface SdkLoader
      Parameters:
      targetHash - the compilation target hash string.
      buildToolRevision - the build tools revision.
      logger - a logger to output messages.
      sdkLibData - a wrapper containing all the components for downloading.
      Returns:
      the target info.
      Throws:
      LicenceNotAcceptedException
      InstallFailedException
    • getSdkInfo

      @NonNull public SdkInfo getSdkInfo(@NonNull com.android.utils.ILogger logger)
      Description copied from interface: SdkLoader
      Returns generic SDK information. This requires loading/parsing the SDK.
      Specified by:
      getSdkInfo in interface SdkLoader
      Parameters:
      logger - a logger to output messages.
      Returns:
      the sdk info.
    • getRepositories

      @NonNull public com.google.common.collect.ImmutableList<File> getRepositories()
      Description copied from interface: SdkLoader
      Returns the location of artifact repositories built-in the SDK.
      Specified by:
      getRepositories in interface SdkLoader
      Returns:
      a non null list of repository folders.
    • installSdkTool

      @Nullable public File installSdkTool(@NonNull SdkLibData sdkLibData, @NonNull String packageId) throws LicenceNotAcceptedException, InstallFailedException
      Description copied from interface: SdkLoader
      Installs an Android Sdk Tool if it's not already installed.
      Specified by:
      installSdkTool in interface SdkLoader
      Parameters:
      sdkLibData - contains all the components for downloading.
      packageId - the package/id path of the required Tool component.
      Returns:
      a File representing the locations to the directory where the Tool component is installed or null if we haven't managed to find such a component.
      Throws:
      LicenceNotAcceptedException
      InstallFailedException
    • retrieveRepoIdsWithPrefix

      @Nullable public com.google.common.collect.ImmutableList<String> retrieveRepoIdsWithPrefix(@NonNull SdkLibData sdkLibData, @NonNull String prefix)
      Description copied from interface: SdkLoader
      Retrieves the hash ids for available remote repositories that start with the given prefix.
      Specified by:
      retrieveRepoIdsWithPrefix in interface SdkLoader
      Parameters:
      sdkLibData - contains all the components for downloading.
      prefix - the prefix for repo hash ids to be retrieved
      Returns:
      a list of hash ids for all remote reps available or null if we are unable to reach the remote server (such as being offline).
    • getLocalEmulator

      @Nullable public File getLocalEmulator(@NonNull com.android.utils.ILogger logger)
      Description copied from interface: SdkLoader
      Retrieves the local emulator repository if it exists.

      If the emulator is missing, null is returned. No effort is made to update or install the emulator as this can invalidate existing avd snapshots.

      Specified by:
      getLocalEmulator in interface SdkLoader
      Returns:
      The location of the emulator, or null if it is not installed.