]> git.saurik.com Git - android/aapt.git/commitdiff
Only output proguard keep for nonempty attribute name in the AndroidManifest.xml.
authorYing Wang <wangying@google.com>
Wed, 13 Jan 2010 00:08:23 +0000 (16:08 -0800)
committerYing Wang <wangying@google.com>
Wed, 13 Jan 2010 00:08:23 +0000 (16:08 -0800)
Before this change, aapt generates proguard keep flags like
"-keep class com.android.somepackage.", which proguard doesn't recognize.

Resource.cpp

index fdcada44a50d32448fbcb9ef7c4d68186bf0208a..02b46aa50852c3c9197d4a76e0e006f79c0a474d 100644 (file)
@@ -1745,31 +1745,33 @@ writeProguardForAndroidManifest(ProguardKeepSet* keep, const sp<AaptAssets>& ass
                     fprintf(stderr, "ERROR: %s\n", error.string());
                     return -1;
                 }
-                // asdf     --> package.asdf
-                // .asdf  .a.b  --> package.asdf package.a.b
-                // asdf.adsf --> asdf.asdf
-                String8 rule("-keep class ");
-                const char* p = name.string();
-                const char* q = strchr(p, '.');
-                if (p == q) {
-                    rule += pkg;
-                    rule += name;
-                } else if (q == NULL) {
-                    rule += pkg;
-                    rule += ".";
-                    rule += name;
-                } else {
-                    rule += name;
-                }
+                if (name.length() > 0) {
+                    // asdf     --> package.asdf
+                    // .asdf  .a.b  --> package.asdf package.a.b
+                    // asdf.adsf --> asdf.asdf
+                    String8 rule("-keep class ");
+                    const char* p = name.string();
+                    const char* q = strchr(p, '.');
+                    if (p == q) {
+                        rule += pkg;
+                        rule += name;
+                    } else if (q == NULL) {
+                        rule += pkg;
+                        rule += ".";
+                        rule += name;
+                    } else {
+                        rule += name;
+                    }
 
-                String8 location = tag;
-                location += " ";
-                location += assFile->getSourceFile();
-                char lineno[20];
-                sprintf(lineno, ":%d", tree.getLineNumber());
-                location += lineno;
+                    String8 location = tag;
+                    location += " ";
+                    location += assFile->getSourceFile();
+                    char lineno[20];
+                    sprintf(lineno, ":%d", tree.getLineNumber());
+                    location += lineno;
 
-                keep->add(rule, location);
+                    keep->add(rule, location);
+                }
             }
         }
     }