Assigned
Status Update
Comments
ja...@google.com <ja...@google.com> #2
Retraced stack trace:
Caused by: java.lang.UnsupportedOperationException: Operation is not supported for read-only collection
at com.android.tools.r8.jetbrains.kotlin.collections.EmptyList.removeAll(Collections.kt)
at com.android.tools.r8.resourceshrinker.r8integration.LegacyResourceShrinker.run(LegacyResourceShrinker.java:228)
at com.android.tools.r8.R8.shrinkResources(R8.java:991)
at com.android.tools.r8.R8.runInternal(R8.java:894)
at com.android.tools.r8.R8.runInternal(R8.java:259)
at com.android.tools.r8.R8.lambda$runForTesting$1(R8.java:243)
at com.android.tools.r8.internal.Nu.a(R8_8.9.27_3afcc9fea5cc5cd06373667ec09d5fe106db8a4a77576689534e667542385a93:28
we...@appnovation.com <we...@appnovation.com> #3
This is happening when there are no unused resources at all and we have duplicated resources between the feature and base (or different features)
Reproduction here:
Fix here:
For the reporter to work around this:
- Disable resource shrinking in this case, it will have no effect since there are no unused resources for this build
- Use legacy AGP embedded shrinker - set android.r8.integratedResourceShrinking false in your settings
- Manually update to a new R8 version (I will post a follow up when this is on our release branch)
Description
Using the insertParagraph() function in Docs to copy header elements produces a Documents services error if there is an image in the header.
I created a Docs add-on to help quickly replace the header and footer sections of our company’s Docs to show our new company logo and text tagline from the old. The add-on referenced a source GDoc with the appropriate header and footer elements based on its document ID and would insert child elements of the HeaderSection, element by element, as the Docs AppScript does not have a “setHeader(header)” type of function.
Code snippet (edited down for brevity):
function onOpen(e) {
var ui = DocumentApp.getUi();
ui.createMenu('Replace Header')
.addItem('With WrapText Image Header','copyAndApplyHeader')
.addToUi();
}
function testFunction(documentID)
{
var sourceDoc = DocumentApp.openById(documentID); // the document to copy the header elements from
var sourceElements = "";
var numElements = 0;
var doc = DocumentApp.getActiveDocument(); // destination document, where you want the header elements copied to to
if (doc.getHeader() == null)
doc.addHeader();
else
doc.getHeader().clear(); // clear the contents of the HeaderSection in the destination document first
sourceElements = sourceDoc.getHeader().copy();
numElements = sourceElements.getNumChildren();
for (var i=0;i<numElements;i++)
doc.getHeader().insertParagraph(i,sourceElements.getChild(i).copy());
}
function copyAndApplyHeader()
{
testFunction("1glCcLcdvQQBdRZW-kcNLPfzgxcG4Uc5SbRscTzCVckQ"); // publicly available GDoc link
}
What steps will reproduce the problem?
Pre-condition: The above code is added via the Script Editor in an empty Doc (the destination doc) permissions have been granted to run the add-on. The document id of the source Doc to copy header elements from is publicly viewable (but not editable).
Steps:
1. Click on the Replace Header > With WrapText Image Header menu option.
What is the expected output? What do you see instead? If you see error messages, please provide them.
Expected behavior: The destination doc’s header should show 3 elements:
1. A smiley image, left-aligned, with the "Wrap text" property set
2. A sentence of text right-aligned, almost middle-aligned to the smiley image
3. A horizontal line beneath both the smiley image and text sentence.
What is seen instead:
An error message with a red background saying: “Service unavailable: Documents”. No elements from the source Doc are copied over to the destination Doc.
Please provide any additional information below.
After some debugging and troubleshooting, it looks like the issue is centered around the insertParagraph() function and if a Paragraph element has an image in it. Specifically, if the image has its layout property set to Wrap text or Break text, it seems to be recognized as a PositionedImage object which isn’t defined as an Element. If however, the image is set to be In line for its layout property, the add-on code behaves as expected, but if it's set to In line, the layouts of the elements won't be able to be shown and positioned nicely as before.
Link to the Positioned Image reference page:
This add-on was deployed within the organization in early June 2019 and worked fine around mid-September 2019 when the error was first noticed.
I have tried to look into workarounds such as recreating the header elements and putting them into table cells, but that apparently is not working as intended either based on this issue logged: