use of com.android.builder.model.AndroidArtifactOutput 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();
}
use of com.android.builder.model.AndroidArtifactOutput in project android by JetBrains.
the class AndroidRootUtil method getApkPath.
@Nullable
public static String getApkPath(@NotNull AndroidFacet facet) {
if (facet.requiresAndroidModel()) {
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
if (androidModuleModel != null) {
// For Android-Gradle projects, AndroidModel is not null.
AndroidArtifact mainArtifact = androidModuleModel.getMainArtifact();
AndroidArtifactOutput output = getOutput(mainArtifact);
File outputFile = output.getMainOutputFile().getOutputFile();
return outputFile.getAbsolutePath();
} else {
return null;
}
}
String path = facet.getProperties().APK_PATH;
if (path.length() == 0) {
return getOutputPackage(facet.getModule());
}
String moduleDirPath = getModuleDirPath(facet.getModule());
return moduleDirPath != null ? toSystemDependentName(moduleDirPath + path) : null;
}
Aggregations