Aapt main dex proguard rules - always keep application
Aapt with -D option was not keeping the application and instrumentation
subclasses, which were instead handled by mainDexClasses.rules. Instead,
include them in the aapt -D output.
Change-Id: Ia3b89fc2edd45d379c4d06f0bf674716646fcb3d
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index a7878d1..b278831 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -2929,6 +2929,19 @@
if (!keepTag && inApplication && depth == 3) {
if (tag == "activity" || tag == "service" || tag == "receiver" || tag == "provider") {
keepTag = true;
+
+ if (mainDex) {
+ String8 componentProcess = AaptXml::getAttribute(tree,
+ "http://schemas.android.com/apk/res/android", "process", &error);
+ if (error != "") {
+ fprintf(stderr, "ERROR: %s\n", error.string());
+ return -1;
+ }
+
+ const String8& process =
+ componentProcess.length() > 0 ? componentProcess : defaultProcess;
+ keepTag = process.length() > 0 && process.find(":") != 0;
+ }
}
}
if (keepTag) {
@@ -2941,19 +2954,6 @@
keepTag = name.length() > 0;
- if (keepTag && mainDex) {
- String8 componentProcess = AaptXml::getAttribute(tree,
- "http://schemas.android.com/apk/res/android", "process", &error);
- if (error != "") {
- fprintf(stderr, "ERROR: %s\n", error.string());
- return -1;
- }
-
- const String8& process =
- componentProcess.length() > 0 ? componentProcess : defaultProcess;
- keepTag = process.length() > 0 && process.find(":") != 0;
- }
-
if (keepTag) {
addProguardKeepRule(keep, name, pkg.string(),
assFile->getPrintableSource(), tree.getLineNumber());