sumgy sumgy - 1 month ago 58
Android Question

Android studio autogenerated xml file has error

After updating to android studio 2.2, the error showed up (--debug):

Error:20:20:53.047 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"error","text":"Tag \u003cwrapItem\u003e can not appear inside \u003cstyle\u003e, only \u003citem\u003e","sources":[{"file":"C:\\Users\\Dan\\AndroidStudioProjects\\myOrderSystem\\app\\build\\intermediates\\res\\merged\\debug\\values\\values.xml","position":{"startLine":354}}],"original":"","tool":"AAPT"}
20:20:53.048 [ERROR] [org.gradle.api.Project] C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\merged\debug\values\values.xml:355: error: Tag <wrapItem> can not appear inside <style>, only <item>

20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter]
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter]
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] * Whenter code hereat went wrong:
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:processDebugResources'.
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: Failed to execute aapt
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter]
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
20:20:53.051 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.


The stacktrace:

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
AGPBI: {"kind":"error","text":"Tag \u003cwrapItem\u003e can not appear inside \u003cstyle\u003e, only \u003citem\u003e","sources":[{"file":"C:\\Users\\Dan\\AndroidStudioProjects\\myOrderSystem\\app\\build\\intermediates\\res\\merged\\debug\\values\\values.xml","position":{"startLine":354}}],"original":"","tool":"AAPT"}
C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\merged\debug\values\values.xml:355: error: Tag <wrapItem> can not appear inside <style>, only <item>



FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:237)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:185)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:82)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 70 more
Caused by: com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:909)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:178)
... 78 more
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing 'C:\Users\Dan\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe' with arguments {package -f --no-crunch -I C:\Users\Dan\AppData\Local\Android\sdk\platforms\android-24\android.jar -M C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\merged\debug -m -J C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\generated\source\r\debug -F C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package com.example.dan.myordersystem -0 apk --preferred-density hdpi --output-text-symbols C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\symbols\debug --no-version-vectors}
at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:907)
... 79 more
Caused by: com.android.ide.common.process.ProcessException: Error while executing 'C:\Users\Dan\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe' with arguments {package -f --no-crunch -I C:\Users\Dan\AppData\Local\Android\sdk\platforms\android-24\android.jar -M C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\merged\debug -m -J C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\generated\source\r\debug -F C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package com.example.dan.myordersystem -0 apk --preferred-density hdpi --output-text-symbols C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\symbols\debug --no-version-vectors}
at com.android.build.gradle.internal.process.GradleProcessResult.buildProcessException(GradleProcessResult.java:75)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:49)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:78)
at com.android.builder.internal.aapt.AbstractProcessExecutionAapt$1.onSuccess(AbstractProcessExecutionAapt.java:74)
at com.google.common.util.concurrent.Futures$6.run(Futures.java:1319)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.android.build.gradle.internal.process.GradleProcessExecutor$1.run(GradleProcessExecutor.java:58)
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Dan\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:47)
... 9 more


BUILD FAILED

Total time: 1.128 secs


the error is apparently in the values.xml C:\Users\Dan\AndroidStudioProjects\myOrderSystem\app\build\intermediates\res\merged\debug\values\values.xml:355:
error: Tag <wrapItem> can not appear inside <style>, only <item>


And this is where the error is (in values.xml):

......
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<wrapItem name="colorPrimary">@color/colorPrimary</wrapItem>
<wrapItem name="colorPrimaryDark">@color/colorPrimaryDark</wrapItem>
<wrapItem name="colorAccent">@color/colorAccent</wrapItem>
</style>
......


If deleting it, it will be regenerated by something after build. Unfortunately, I can't find which file produces values.xml.

And here is the build.gradle(Module: app):

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
repositories{
jcenter()
}
defaultConfig {
applicationId "com.example.dan.myordersystem"
minSdkVersion 11
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
// compile 'com.google.code.gson:gson:2.3.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/gcm.jar')
// compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
}


The problem is I can not modify values.xml directly. Each time I build the project, values.xml just recover to the same error code. Seems like something regenerating values.xml after build so I should find some way to change the values.xml but I don't know how.

Does anyone have any ideas? Please help.

Answer

Thanks for answers. Though I solve the problem, not finding the answer. I just create another new project, and literally create the file with the same name as the old project. Then, inspect old codes and copy to new file. It took me quite a while. There is something interesting I found. Certain key codes in some xml files, "item", were modified to "wrapItem". It looks like there is something wrong happened when updating the project.

Can not copy files. (copy files: all .java files, gradle files, and manifest) Copying files directly will result in the same issue.

From now on, I could say, "I kind of scare updating project..."