AxmlNet is a high-performance .NET Standard 2.1 library designed to decode Android Binary XML (AXML) files and extract them directly from APK or APKS (Split APK) containers. It supports both binary and plain text XML files with advanced format detection and optimized performance.
- Smart Decoding: Automatically detects and decodes Binary AXML or plain text XML formats transparently.
- APK & APKS Support: Extract XML files seamlessly from standard
.apkfiles and.apks(Split APK) bundles. - Specialized Manifest Extraction: Dedicated
ApkManifestExtractorfor robust extraction and conversion ofAndroidManifest.xmlfiles, including handling multi-APK split containers. - High-Performance Sniffing: Utilizes
ReadOnlySpan<byte>andBinaryPrimitivesfor zero-allocation, fast header parsing and format identification.
Install via the .NET CLI:
dotnet add package AxmlNetExtract and convert manifests from APK or APKS containers, including all splits in a .apks bundle:
// Extract all manifests (for example, from an .apks split APK bundle)
var manifests = ApkManifestExtractor.ExtractBinaryManifests("app.apks");
foreach (var manifest in manifests)
{
Console.WriteLine($"Manifest extracted from: {manifest.SourceName}");
string xml = manifest.ConvertToXml();
Console.WriteLine(xml);
}
// Extract and convert the main manifest from a single APK file
string mainManifestXml = ApkManifestExtractor.ConvertManifestToXml("app.apk");
Console.WriteLine(mainManifestXml);Extract any XML file (layouts, configs) from an APK or APKS:
string xmlContent = ApkBinaryXmlExtractor.GetXmlContent("app.apk", "res/xml/network_security_config.xml");
Console.WriteLine(xmlContent);Manually convert a binary AXML stream to a formatted XML string:
using var stream = File.OpenRead("binary_layout.xml");
var options = new AxmlConverterOptions { Indent = true, WriteXmlDeclaration = true };
string xml = AxmlConverter.ConvertToXmlString(stream, options);
Console.WriteLine(xml);The library identifies Binary AXML files by validating the Android resource chunk header (ResChunk_header):
- Chunk Type:
0x0003(RES_XML_TYPE) - Header Size:
0x0008 - Data Integrity: The internal
totalSizefield is checked to ensure consistency with the actual byte stream length.
For non-binary files, AxmlNet applies a heuristic approach to determine the text encoding:
- Attempts to detect standard Byte Order Marks (BOM) for UTF-8 and UTF-16 (LE/BE).
- If BOM is absent, analyzes the first 512 bytes for null-byte frequency.
- If null bytes exceed 10% within the sample, assumes UTF-16 LE encoding; otherwise, defaults to UTF-8.
- .NET Standard 2.1
- Dependencies:
System.Memory,System.IO.Compression
Licensed under the MIT License.