use of com.android.build.OutputFile in project kotlin by JetBrains.
the class Project method getApplicableDensities.
/**
* Returns the set of applicable densities for this project. If null, there are no density
* restrictions and all densities apply.
*
* @return the list of specific densities that apply in this project, or null if all densities
* apply
*/
@Nullable
public List<String> getApplicableDensities() {
if (mCachedApplicableDensities == null) {
// ...then we should only enforce hdpi densities, not all these others!
if (isGradleProject() && getGradleProjectModel() != null && getCurrentVariant() != null) {
Set<String> relevantDensities = Sets.newHashSet();
Variant variant = getCurrentVariant();
List<String> variantFlavors = variant.getProductFlavors();
AndroidProject gradleProjectModel = getGradleProjectModel();
addResConfigsFromFlavor(relevantDensities, null, getGradleProjectModel().getDefaultConfig());
for (ProductFlavorContainer container : gradleProjectModel.getProductFlavors()) {
addResConfigsFromFlavor(relevantDensities, variantFlavors, container);
}
// Are there any splits that specify densities?
if (relevantDensities.isEmpty()) {
AndroidArtifact mainArtifact = variant.getMainArtifact();
Collection<AndroidArtifactOutput> outputs = mainArtifact.getOutputs();
for (AndroidArtifactOutput output : outputs) {
for (OutputFile file : output.getOutputs()) {
final String DENSITY_NAME = OutputFile.FilterType.DENSITY.name();
if (file.getFilterTypes().contains(DENSITY_NAME)) {
for (FilterData data : file.getFilters()) {
if (DENSITY_NAME.equals(data.getFilterType())) {
relevantDensities.add(data.getIdentifier());
}
}
}
}
}
}
if (!relevantDensities.isEmpty()) {
mCachedApplicableDensities = Lists.newArrayListWithExpectedSize(10);
for (String density : relevantDensities) {
String folder = ResourceFolderType.DRAWABLE.getName() + '-' + density;
mCachedApplicableDensities.add(folder);
}
Collections.sort(mCachedApplicableDensities);
} else {
mCachedApplicableDensities = Collections.emptyList();
}
} else {
mCachedApplicableDensities = Collections.emptyList();
}
}
return mCachedApplicableDensities.isEmpty() ? null : mCachedApplicableDensities;
}
use of com.android.build.OutputFile in project android by JetBrains.
the class GradleApkProvider method getApk.
@NotNull
private static File getApk(@NotNull Variant variant, @NotNull IDevice device) throws ApkProvisionException {
AndroidArtifact mainArtifact = variant.getMainArtifact();
List<AndroidArtifactOutput> outputs = Lists.newArrayList(mainArtifact.getOutputs());
if (outputs.isEmpty()) {
throw new ApkProvisionException("No outputs for the main artifact of variant: " + variant.getDisplayName());
}
List<String> abis = device.getAbis();
int density = device.getDensity();
Set<String> variantAbiFilters = mainArtifact.getAbiFilters();
List<OutputFile> apkFiles = SplitOutputMatcher.computeBestOutput(outputs, variantAbiFilters, density, abis);
if (apkFiles.isEmpty()) {
String message = AndroidBundle.message("deployment.failed.splitapk.nomatch", variant.getDisplayName(), outputs.size(), density, Joiner.on(", ").join(abis));
throw new ApkProvisionException(message);
}
return apkFiles.get(0).getOutputFile();
}
Aggregations