I m trying to use shrinkResources and its failing at the build time. I don't see any issue when I don't shrinkResources
. I have following configurations:
minifyEnabled true
shrinkResources true
gradle versions
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'net.sf.proguard:proguard-gradle:5.3.3'
and
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
.
I have also seen many people out here facing the same issue with some recommended solutions like:
- turn on minifyEnabled true in order to use shrinkResources true, which I m already doing it.
- Some recommended to turn off shrink resource by shrinkResources false in order to build the app, but I need to use shrinkResources and so it doesn't apply to me.
- There were some recommendation/suggestions that gradle plugin has/had a bug, and I should use plugin version < 2.2, which I can't at this point of time.
Highly appreciate if someone from the community helps me out here.
Below is the log that I m seeing in the gradle console:
:app:transformClassesWithShrinkResForJenkinsRelease
[Fatal Error] :1:1: Content is not allowed in prolog.
Failed to shrink resources: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.; ignoring
Failed to shrink resources: ignoring
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at com.android.utils.XmlUtils.parseDocument(XmlUtils.java:493)
at com.android.utils.XmlUtils.parseDocument(XmlUtils.java:474)
at com.android.build.gradle.tasks.ResourceUsageAnalyzer.recordResources(ResourceUsageAnalyzer.java:1177)
at com.android.build.gradle.tasks.ResourceUsageAnalyzer.recordResources(ResourceUsageAnalyzer.java:1160)
at com.android.build.gradle.tasks.ResourceUsageAnalyzer.analyze(ResourceUsageAnalyzer.java:276)
at com.android.build.gradle.internal.transforms.ShrinkResourcesTransform.transform(ShrinkResourcesTransform.java:209)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
:app:mergeJenkinsReleaseJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForJenkinsRelease
:app:validateSigningJenkinsRelease
:app:packageJenkinsRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:packageJenkinsRelease'.
> File '/Users/rbc/Documents/GitLab/MyAPPName/app/build/intermediates/res/resources-jenkins-release-stripped.ap_' specified for property 'resourceFile' does not exist.
.
.
Apart from this, if anyone think they need extra information to understand my scenario, please feel free to let me know and I will post the information as much as I could here in the question section.
3条答案
按热度按时间whitzsjs1#
对我来说,它工作得很好,我正在使用
在proguard-rules.pro中,我有
我想我在添加
-dontoptimize
之前遇到了问题hof1towb2#
我也有类似的问题-
经过一番冥思苦想之后,我意识到之前的git合并留下了一个空的.xml文件,这导致了它的崩溃。我删除了这个空文件,现在任务成功了。
z9zf31ra3#
什么救了我是删除一个空文件.xml文件在android/app/src/main/res/xml
这是我在android/app/build.gradle中的配置
所以基本上这是我在网上找到的一些不同解决方案的混合