from Assets
Recommended Android setup — loads a TrustPinConfiguration from a JSON file bundled in the application's assets/ directory.
This is the primary Android entry point for TrustPin.setup, the one to use whenever a bundled trustpin.json is acceptable for shipping credentials. The other recommended Android path is TrustPinConfiguration.withAndroidStorage — used directly when the configuration is built programmatically rather than loaded from a file. The returned configuration is already wired to the supplied Context, so callers do not need to chain anything else.
Convention (mirrors google-services.json): place the file at src/main/assets/trustpin.json in your application module. For per-flavor or per-build-type overrides, drop a file with the same name into the matching variant source set — the Android Gradle Plugin's asset merging will pick the right one per variant. For example:
app/src/main/assets/trustpin.json ← default
app/src/debug/assets/trustpin.json ← overrides for the debug build type
app/src/ff/assets/trustpin.json ← overrides for the "ff" product flavorNo Gradle plugin is required — the routing happens via standard Android source sets.
The returned configuration applies to TrustPin.default. Named instances created via TrustPin.instance continue to use programmatic construction (build the configuration yourself and chain .withAndroidStorage(context)); this loader does not support multi-instance files.
From Kotlin:
val config = TrustPinConfiguration.fromAssets(context)
TrustPin.setup(config)From Java:
TrustPinConfiguration config = TrustPinConfigurationAssets.fromAssets(context);
TrustPin.getDefault().setupBlocking(config);Return
A TrustPinConfiguration already wired to the supplied Context; pass it directly to TrustPin.setup. Single-use — see withAndroidStorage.
File schema (snake_case)
{
"organization_id": "my-org",
"project_id": "my-project",
"public_key": "MFkwEwYH...",
"mode": "strict",
"configuration_url": "https://custom.example.com/config/signed.b64"
}organization_id, project_id, public_key are required. mode is "strict" (default) or "permissive". configuration_url is optional; if present must use HTTPS. Unknown top-level keys are ignored for forward compatibility.
Parameters
Any Android Context — application context is preferred so the assets manager outlives the call site.
Override for the asset filename. Defaults to "trustpin.json".
Throws
if the file is missing, unreadable, or has invalid contents. A descriptive message is written to logcat under the [TrustPin] tag.
Kotlin call-site sugar so customers can write TrustPinConfiguration.fromAssets(context).
Delegates to the shared loadFromAssetsImpl — NOT to the top-level fromAssets — because inside this extension function the implicit receiver is TrustPinConfiguration.Companion, which makes Kotlin's overload resolution pick this same function over the receiver-less top-level one. Routing through a private impl avoids that recursion.
Renamed at the JVM level to fromAssetsForCompanion so the two declarations don't collide in the generated TrustPinConfigurationAssets class file. Annotated JvmSynthetic so Java callers see only the top-level fromAssets in autocomplete — Java has no use for the companion-receiver form.