Android即时运行gradle错误

时间:2016-10-19 10:28:43

标签: android gradle android-gradle android-instant-run

有时当我使用即时运行时,我会收到此错误(主要是在layout.xml更改后):

  

失败:构建因异常而失败。

     
      
  • 出了什么问题:任务执行失败':wear:transformClassesWithNewClassShrinkerForDevDebug'。

         
        

    java.lang.IllegalArgumentException异常

      
  •   
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--debug选项运行以获得更多日志输出。

  •   

现在我的项目需要重建,否则不会运行并继续给我同样的错误 但是,如果不是重新重新构建它,我会使用./gradlew :wear:assembleDevDebug :wear:transformClassesWithNewClassShrinkerForDevDebug构建的cmd,我可以再次运行它,但是即时运行会丢失。

所以当我尝试即时运行时失败但是当使用cmd时它没有?为什么会这样? 感谢。

修改 在Google代码here

中打开了一个问题

编辑2: 要在cmd中重现此错误,我必须更改layout.xml,例如注释视图,然后运行:wear:transformClassesWithNewClassShrinkerForDevDebug
输出:

  

失败:构建因异常而失败。

     
      
  • 出了什么问题:任务执行失败':wear:transformClassesWithNewClassShrinkerForDevDebug'。

         
        

    java.lang.IllegalArgumentException异常

      
  •   
  • 尝试:使用--info或--debug选项运行以获取更多日志输出。

  •   
  • 异常是:org.gradle.api.tasks.TaskExecutionException:任务执行失败   ':穿:transformClassesWithNewClassShrinkerForDevDebug&#39 ;.       at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)       在org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)       在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)       在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)       在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)       在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)       在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)       在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)       at org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)       at org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)       在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)       在org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)       在org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)       在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)       在org.gradle.execution.DefaultBuildExecuter.access $ 000(DefaultBuildExecuter.java:23)       在org.gradle.execution.DefaultBuildExecuter $ 1.proceed(DefaultBuildExecuter.java:43)       在org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)       在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)       在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)       在org.gradle.initialization.DefaultGradleLauncher $ 4.run(DefaultGradleLauncher.java:153)       在org.gradle.internal.Factories $ 1.create(Factories.java:22)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)       在org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)       在org.gradle.initialization.DefaultGradleLauncher.access $ 200(DefaultGradleLauncher.java:32)       在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:98)       在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:92)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)       在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)       在org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)       在org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)       at org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter.java:99)       在org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)       在org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)       at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)       在org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)       在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)       在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)       在org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)       在org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)       在org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)       在org.gradle.internal.Actions $ RunnableActionAdapter.execute(Actions.java:173)       在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:239)       在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:212)       在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)       在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)       在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)       在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)       在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:205)       在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:169)       在org.gradle.launcher.Main.doAction(Main.java:33)       在org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)       在org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)       在org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)       在org.gradle.launcher.GradleMain.main(GradleMain.java:23)       在org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)       在org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)       在org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)   引起:java.lang.RuntimeException:   java.lang.IllegalArgumentException异常       在com.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:147)       在com.android.build.gradle.shrinker.AbstractShrinker.waitForAllTask​​s(AbstractShrinker.java:347)       在com.android.build.gradle.shrinker.IncrementalShrinker.waitForAllTask​​s(IncrementalShrinker.java:275)       在com.android.build.gradle.shrinker.IncrementalShrinker.processInputs(IncrementalShrinker.java:241)       在com.android.build.gradle.shrinker.IncrementalShrinker.incrementalRun(IncrementalShrinker.java:96)       在com.android.build.gradle.internal.transforms.NewShrinkerTransform.incrementalRun(NewShrinkerTransform.java:220)       在com.android.build.gradle.internal.transforms.NewShrinkerTransform.transform(NewShrinkerTransform.java:119)       在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:178)       在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:174)       在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)       在com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)       在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)       at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.doExecute(AnnotationProcessingTaskFactory.java:245)       在org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)       at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.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)       在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)       ... 60更多引起:java.lang.IllegalArgumentException       在org.objectweb.asm.ClassReader。(未知来源)       在org.objectweb.asm.ClassReader。(未知来源)       在com.android.build.gradle.shrinker.IncrementalShrinker.processChangedClassFile(IncrementalShrinker.java:262)       在com.android.build.gradle.shrinker.IncrementalShrinker.access $ 000(IncrementalShrinker.java:47)       在com.android.build.gradle.shrinker.IncrementalShrinker $ 1.call(IncrementalShrinker.java:229)       在com.android.build.gradle.shrinker.IncrementalShrinker $ 1.call(IncrementalShrinker.java:216)

  •   
     

建立失败

     

总时间:11.114秒

1 个答案:

答案 0 :(得分:1)

Android Studio 2.3 Canary 2现已推出,它解决了这个问题。