X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/9753ece40a5044dca290c43f310752954e572fbc..9cf1eae99dfeb475960ee74d8f010def438769a3:/Resource.cpp diff --git a/Resource.cpp b/Resource.cpp index 76b9d0a..41ee88b 100644 --- a/Resource.cpp +++ b/Resource.cpp @@ -174,7 +174,7 @@ static sp getResourceFile(const sp& assets, bool makeIfNec static status_t parsePackage(const sp& assets, const sp& grp) { if (grp->getFiles().size() != 1) { - fprintf(stderr, "WARNING: Multiple AndroidManifest.xml files found, using %s\n", + fprintf(stderr, "warning: Multiple AndroidManifest.xml files found, using %s\n", grp->getFiles().valueAt(0)->getPrintableSource().string()); } @@ -419,14 +419,14 @@ static void checkForIds(const String8& path, ResXMLParser& parser) if (code == ResXMLTree::START_TAG) { ssize_t index = parser.indexOfAttribute(NULL, "id"); if (index >= 0) { - fprintf(stderr, "%s:%d: WARNING: found plain 'id' attribute; did you mean the new 'android:id' name?\n", + fprintf(stderr, "%s:%d: warning: found plain 'id' attribute; did you mean the new 'android:id' name?\n", path.string(), parser.getLineNumber()); } } } } -static void applyFileOverlay(const sp& assets, +static bool applyFileOverlay(const sp& assets, const sp& baseSet, const char *resType) { @@ -434,7 +434,7 @@ static void applyFileOverlay(const sp& assets, // Also add any found only in the overlay. sp overlay = assets->getOverlay(); String8 resTypeString(resType); - + // work through the linked list of overlays while (overlay.get()) { KeyedVector >* overlayRes = overlay->getResources(); @@ -449,7 +449,7 @@ static void applyFileOverlay(const sp& assets, size_t overlayCount = overlaySet->size(); for (size_t overlayIndex=0; overlayIndexindexOfKey(overlaySet->keyAt(overlayIndex)); - if (baseIndex != UNKNOWN_ERROR) { + if (baseIndex < UNKNOWN_ERROR) { // look for same flavor. For a given file (strings.xml, for example) // there may be a locale specific or other flavors - we want to match // the same flavor. @@ -475,9 +475,10 @@ static void applyFileOverlay(const sp& assets, } } else { // this group doesn't exist (a file that's only in the overlay) - // add it - baseSet->add(overlaySet->keyAt(overlayIndex), - overlaySet->valueAt(overlayIndex)); + fprintf(stderr, "aapt: error: " + "*** Resource file '%s' exists only in an overlay\n", + overlaySet->keyAt(overlayIndex).string()); + return false; } } // this overlay didn't have resources for this type @@ -485,7 +486,7 @@ static void applyFileOverlay(const sp& assets, // try next overlay overlay = overlay->getOverlay(); } - return; + return true; } void addTagAttribute(const sp& node, const char* ns8, @@ -611,13 +612,15 @@ status_t buildResources(Bundle* bundle, const sp& assets) current = current->getOverlay(); } // apply the overlay files to the base set - applyFileOverlay(assets, drawables, "drawable"); - applyFileOverlay(assets, layouts, "layout"); - applyFileOverlay(assets, anims, "anim"); - applyFileOverlay(assets, xmls, "xml"); - applyFileOverlay(assets, raws, "raw"); - applyFileOverlay(assets, colors, "color"); - applyFileOverlay(assets, menus, "menu"); + if (!applyFileOverlay(assets, drawables, "drawable") || + !applyFileOverlay(assets, layouts, "layout") || + !applyFileOverlay(assets, anims, "anim") || + !applyFileOverlay(assets, xmls, "xml") || + !applyFileOverlay(assets, raws, "raw") || + !applyFileOverlay(assets, colors, "color") || + !applyFileOverlay(assets, menus, "menu")) { + return UNKNOWN_ERROR; + } bool hasErrors = false;