Throw contextual error when compiling value xmls with >1 period in filename with aapt2, instead of just failing with "<file>.arsc.flat does not exist after aapt2 ran":
SEVERE: aapt2 does not support compiling resource xmls with multiple periods in the filename: Style.Cell.xml
Closes
@@ -172,10 +172,29 @@ public class ResourceCompiler {
}
static String interpolateAapt2Filename(Qualifiers qualifiers, String filename) {
- return qualifiers.asFolderType().equals(ResourceFolderType.VALUES)
- ? (filename.indexOf('.') != -1 ? filename.substring(0, filename.indexOf('.')) : filename)
- + ".arsc"
- : filename;
+ // res/<not values>/foo.bar -> foo.bar
+ if (!qualifiers.asFolderType().equals(ResourceFolderType.VALUES)) {
+ return filename;
+ }
+
+ int periodIndex = filename.indexOf('.');
+
+ // res/values/foo -> foo.arsc
+ if (periodIndex == -1) {
+ return filename + ".arsc";
+ }
+
+ // res/values/foo.bar.baz -> throw error.
+ if (filename.lastIndexOf('.') != periodIndex) {
+ throw new CompileError(
+ new IllegalArgumentException(
+ "aapt2 does not support compiling resource xmls with multiple periods in the "
+ + "filename: "
+ + filename));
+ }
+
+ // res/values/foo.xml -> foo.arsc
+ return filename.substring(0, periodIndex) + ".arsc";
}
private void compile(
