pub struct Aapt2Compile { /* private fields */ }Expand description
§Compile
AAPT2 supports compilation of all Android resource types, such as drawables and XML files. When you invoke AAPT2 for compilation, you should pass a single resource file as an input per invocation. AAPT2 then parses the file and generates an intermediate binary file with a .flat extension.
Although you can pass resource directories containing more than one resource files to AAPT2 using the –dir flag, you do not gain the benefits of incremental resource compilation when doing so. That is, when passing whole directories, AAPT2 recompiles all files in the directory even when only one resource has changed.
The output file types can differ based on the input you provide for compilation. The files AAPT2 outputs are not executables and you must later include these binary files as input in the link phase to generate an APK. However, the generated APK file is not an executable that you can deploy on an Android device right away, as it does not contain DEX files (compiled bytecode) and is not signed.
§Compile syntax
The general syntax for using compile is as follows:
aapt2 compile path-to-input-files [options] -o output-directory/§Note
For resource files, the path to input files must match the following structure:
path/resource-type[-config]/fileIn the following example, AAPT2 compiles resource files named values.xml and myImage.png individually:
aapt2 compile project_root/module_root/src/main/res/values-en/strings.xml -o compiled/
aapt2 compile project_root/module_root/src/main/res/drawable/myImage.png -o compiled/As shown in the table above, the name of the output file depends on the input file name and the name of its parent directory (the resource type and configuration). For the example above with strings.xml as input, aapt2 automatically names the output file as values-en_strings.arsc.flat. On the other hand, the file name for the compiled drawable file stored in the drawable directory will be drawable_img.png.flat.
Implementations§
Source§impl Aapt2Compile
impl Aapt2Compile
pub fn new(input: &Path, o: &Path) -> Self
pub fn dir(&mut self, dir: &Path) -> &mut Self
pub fn pseudo_localize(&mut self) -> &mut Self
pub fn no_crunch(&mut self) -> &mut Self
pub fn legacy(&mut self) -> &mut Self
pub fn v(&mut self) -> &mut Self
pub fn run(&self)
Auto Trait Implementations§
impl Freeze for Aapt2Compile
impl RefUnwindSafe for Aapt2Compile
impl Send for Aapt2Compile
impl Sync for Aapt2Compile
impl Unpin for Aapt2Compile
impl UnwindSafe for Aapt2Compile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more