use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMerger method merge.
private AndroidManifest merge(Map<BundleModuleName, AndroidManifest> manifests) {
AndroidManifest baseManifest = manifests.get(BASE_MODULE_NAME);
List<AndroidManifest> featureManifests = manifests.entrySet().stream().filter(entry -> !BASE_MODULE_NAME.equals(entry.getKey())).sorted(Comparator.comparing(entry -> entry.getKey().getName())).map(Map.Entry::getValue).collect(toImmutableList());
if (featureManifests.isEmpty()) {
return baseManifest;
}
return mergeManifests(baseManifest, featureManifests);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class AndroidManifestValidator method validateInstant.
private static void validateInstant(BundleModule module) {
AndroidManifest manifest = module.getAndroidManifest();
Optional<Boolean> isInstantModule = manifest.isInstantModule();
if (isInstantModule.orElse(false)) {
// if it is an instant module, ensure that max sdk is > 21, as we cannot serve anything less
Optional<Integer> maxSdk = manifest.getMaxSdkVersion();
if (maxSdk.isPresent() && maxSdk.get() < MIN_INSTANT_SDK_VERSION) {
throw InvalidBundleException.builder().withUserMessage("maxSdkVersion (%d) is less than minimum sdk allowed for instant apps (%d).", maxSdk.get(), MIN_INSTANT_SDK_VERSION).build();
}
}
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class AndroidManifestValidator method validateAssetModuleManifest.
private static void validateAssetModuleManifest(BundleModule module) {
ImmutableMultimap<String, String> allowedManifestElementChildren = ImmutableMultimap.of(DISTRIBUTION_NAMESPACE_URI, "module", NO_NAMESPACE_URI, "uses-split");
AndroidManifest manifest = module.getAndroidManifest();
if (!manifest.getModuleType().equals(ModuleType.ASSET_MODULE)) {
return;
}
if (manifest.getManifestRoot().getElement().getChildrenElements().anyMatch(child -> !allowedManifestElementChildren.containsEntry(child.getNamespaceUri(), child.getName()))) {
throw InvalidBundleException.builder().withUserMessage("Unexpected element declaration in manifest of asset pack '%s'.", module.getName()).build();
}
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class SdkAndroidManifestValidator method validateModule.
@Override
public void validateModule(BundleModule module) {
AndroidManifest manifest = module.getAndroidManifest();
validateSingleSdkLibrary(manifest);
validateVersioningTagsSet(manifest);
validateInternalOnlyIfInstallLocationSet(manifest);
validateNoPermissions(manifest);
validateNoSharedUserId(manifest);
validateNoComponents(manifest);
validateNoSplitId(manifest);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class SameTargetingMergerTest method mergerRejects_conflictingManifests.
/**
* At the moment, the merger doesn't support merging two different android manifests so we check
* that we reject cases where manifest is different within a set chosen for unification.
*/
@Test
public void mergerRejects_conflictingManifests() throws Exception {
AndroidManifest manifest1 = AndroidManifest.create(androidManifest("com.test.app1"));
AndroidManifest manifest2 = AndroidManifest.create(androidManifest("com.test.app2"));
ModuleSplit split1 = createModuleSplitBuilder().setAndroidManifest(manifest1).build();
ModuleSplit split2 = createModuleSplitBuilder().setAndroidManifest(manifest2).build();
Throwable exception = assertThrows(IllegalStateException.class, () -> new SameTargetingMerger().merge(ImmutableList.of(split1, split2)));
assertThat(exception).hasMessageThat().contains("two distinct manifests");
}
Aggregations