Skip to content

Commit 002f537

Browse files
author
Ying Wang
committed
Apply --extra-packages in case --custom-pacakge is also specified.
Cherry-picked from master. Change-Id: I2d67b8821afdf064f4186ccd8def1b65f9a7dc88
1 parent 64ac862 commit 002f537

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

tools/aapt/Command.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,27 +1740,30 @@ int doPackage(Bundle* bundle)
17401740
// Write the R.java file into the appropriate class directory
17411741
// e.g. gen/com/foo/app/R.java
17421742
err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
1743-
// If we have library files, we're going to write our R.java file into
1744-
// the appropriate class directory for those libraries as well.
1745-
// e.g. gen/com/foo/app/lib/R.java
1746-
if (bundle->getExtraPackages() != NULL) {
1747-
// Split on colon
1748-
String8 libs(bundle->getExtraPackages());
1749-
char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
1750-
while (packageString != NULL) {
1751-
// Write the R.java file out with the correct package name
1752-
err = writeResourceSymbols(bundle, assets, String8(packageString), true);
1753-
packageString = strtok(NULL, ":");
1754-
}
1755-
libs.unlockBuffer();
1756-
}
17571743
} else {
17581744
const String8 customPkg(bundle->getCustomPackage());
17591745
err = writeResourceSymbols(bundle, assets, customPkg, true);
17601746
}
17611747
if (err < 0) {
17621748
goto bail;
17631749
}
1750+
// If we have library files, we're going to write our R.java file into
1751+
// the appropriate class directory for those libraries as well.
1752+
// e.g. gen/com/foo/app/lib/R.java
1753+
if (bundle->getExtraPackages() != NULL) {
1754+
// Split on colon
1755+
String8 libs(bundle->getExtraPackages());
1756+
char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
1757+
while (packageString != NULL) {
1758+
// Write the R.java file out with the correct package name
1759+
err = writeResourceSymbols(bundle, assets, String8(packageString), true);
1760+
if (err < 0) {
1761+
goto bail;
1762+
}
1763+
packageString = strtok(NULL, ":");
1764+
}
1765+
libs.unlockBuffer();
1766+
}
17641767
} else {
17651768
err = writeResourceSymbols(bundle, assets, assets->getPackage(), false);
17661769
if (err < 0) {

0 commit comments

Comments
 (0)