Resand
Resand (RESesource ANDroid) is a library for android resource reading and writing. It can read and write AXML (ResXML) and ARSC (ResTable) files.
It is pretty minimal, it does not turn the resource data into xml or any other more friendly format, modifying or reading the data from a resource has to be done manually in rust.
The purpose of this crate is that I wanted to be able to change the app name and package name of an apk without including a large dependency such as apktool, or aapt, or any other similar external tool.
There is not much documentation as this was just something I needed for one of my other projects. And it definitely has bugs and stuff. So good luck using this lol.
A lot of the code is based off of the Android Source Code
Usage
The following examples use .unwrap(), but obviously you should handle errors properly.
Basic reading and writing of and xml tree:
use XMLTree;
use File;
let mut file = open.unwrap;
let tree = read.unwrap;
dbg!;
let mut output = create.unwrap;
tree.write.unwrap;
Basic reading and writing of a resource table:
use ResTable
use File;
let mut file = open.unwrap;
let table = read_all.unwrap;
dbg!;
let mut output = create.unwrap;
table.write_all.unwrap;
Setting the app name:
let xml = read;
let mut table = read_all
let application = xml
.root
.get_elements
.pop
.unwrap;
let attr = application
.get_attribute.unwrap;
if let Reference = attr.typed_value.data
table.write_all
Setting the package name:
let mut xml =
let mut table =
let package = table.packages.first_mut.unwrap;
package.name = "new.package.name".to_string;
let root_element = xml
.root
.get_elements_mut
.pop.unwrap;
let attr = root_element
.get_attribute_mut.unwrap;
attr.write_string;
// you might need to modify other parts of the manifest if they also refer to the package name
xml.write;
table.write_all;
License
Resand is licensed under the Apache-2.0 license which can be read here