Reduce Android AAR size with header-only Prefab (#4483)

This commit is contained in:
Bart Louwers
2026-08-14 16:37:28 +02:00
committed by GitHub
parent 6485d28b3e
commit 95a977e12e
2 changed files with 16 additions and 2 deletions

View File

@@ -1,10 +1,14 @@
#pragma once
#include <mbgl/gfx/context.hpp>
#include <mbgl/style/layers/custom_layer_init_parameters.hpp>
#include <mbgl/style/layers/custom_layer_render_parameters.hpp>
namespace mbgl {
namespace gfx {
class Context;
} // namespace gfx
namespace style {
class CustomLayerHost {

View File

@@ -204,7 +204,7 @@ android {
prefab {
create("maplibre") {
headers = "../prefab-headers"
libraryName = "libmaplibre"
headerOnly = true
}
}
@@ -240,6 +240,16 @@ tasks.configureEach {
}
}
// AGP 9.1.1 still adds the native build output to the AAR even when the Prefab module is
// declared header-only. Keep the header-only metadata and omit that redundant unstripped copy.
tasks.withType<org.gradle.api.tasks.bundling.Zip>().configureEach {
if (name.startsWith("bundle") && name.endsWith("Aar")) {
// The Prefab artifact is added under a `prefab/` destination by a nested copy spec,
// so its paths are still relative to the Prefab root when exclusions are evaluated.
exclude("modules/maplibre/libs/**")
}
}
configurations {
getByName("implementation") {
exclude(group = "commons-logging", module = "commons-logging")