From e8e91925074479fc06310418b58b54f49d051801 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 6 Aug 2014 17:41:08 -0700 Subject: [PATCH] Have styleable indices be non-final for library projects Invoking aapt after merging resources from a library project may yield a different ordering to styleable arrays, so have the indices be non-final too. Bug:16842410 Change-Id: I0432bea03dc4312d5908a770fc70a11f0a1596ae --- tools/aapt/Resource.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index 4f1d15ec23e1b..ec284c5539c12 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -1739,7 +1739,7 @@ static String16 getAttributeComment(const sp& assets, static status_t writeLayoutClasses( FILE* fp, const sp& assets, - const sp& symbols, int indent, bool includePrivate) + const sp& symbols, int indent, bool includePrivate, bool nonConstantId) { const char* indentStr = getIndentSpace(indent); if (!includePrivate) { @@ -1957,8 +1957,13 @@ static status_t writeLayoutClasses( getSymbolName(name8).string()); fprintf(fp, "%s*/\n", indentStr); ann.printAnnotations(fp, indentStr); + + const char * id_format = nonConstantId ? + "%spublic static int %s_%s = %d;\n" : + "%spublic static final int %s_%s = %d;\n"; + fprintf(fp, - "%spublic static final int %s_%s = %d;\n", + id_format, indentStr, nclassName.string(), flattenSymbol(name8).string(), (int)pos); } @@ -2177,7 +2182,7 @@ static status_t writeSymbolClass( } if (styleableSymbols != NULL) { - err = writeLayoutClasses(fp, assets, styleableSymbols, indent, includePrivate); + err = writeLayoutClasses(fp, assets, styleableSymbols, indent, includePrivate, nonConstantId); if (err != NO_ERROR) { return err; }