在Android Studio终端中运行时出现IO异常[重复]

Posted

技术标签:

【中文标题】在Android Studio终端中运行时出现IO异常[重复]【英文标题】:Got IO Exception When running in Android Studio Terminal [duplicate] 【发布时间】:2018-05-14 06:03:39 【问题描述】:

我有一个 android 项目。我已经集成了一些新代码。我已经添加了不要对该文件夹本身发出警告。

  -dontwarn com.myapp.mobile.util**

在我在 android studio 终端中运行构建之后。得到以下异常不知道该怎么做。我无法理解日志。

         [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
        15:51:11.735 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':myApp:transformClassesAndResourcesWithProguardForRelease'.
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Job failed, see logs for details
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
        15:51:11.736 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task '::transformClassesAndResourcesW
        ithProguardForRelease'.
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:1
        00)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingState
        Executer.java:54)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.j
        ava:88)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskEx
        ecuter.java:52)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52
        )
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43
        )
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:2
        48)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperati
        onExecutor.java:336)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperati
        onExecutor.java:328)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java
        :241)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java
        :230)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:
        124)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:8
        0)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:10
        5)
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99
        )
        15:51:11.737 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.RuntimeException: Job failed, see logs for details
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskCl
        assInfoStore.java:173)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassIn
        foStore.java:134)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassIn
        foStore.java:121)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperati
        onExecutor.java:336)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperati
        onExecutor.java:328)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:11
        1)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:9
        2)
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 27 more
        15:51:11.738 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.io.IOException: Please correct the above warnings first.
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at proguard.Initializer.execute(Initializer.java:473)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at proguard.ProGuard.initialize(ProGuard.java:233)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at proguard.ProGuard.execute(ProGuard.java:98)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:253)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.tasks.Job.runTask(Job.java:47)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:259)
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
        15:51:11.739 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2m 19s

任何人都可以让我了解这个例外。

这是我的模块的 build.gradle 文件

    buildscript 
      dependencies 
          classpath 'com.android.tools.build:gradle:2.1.2'
      
      
        android 
            compileSdkVersion 26
            buildToolsVersion "26.0.3"

            defaultConfig 
                applicationId "com.myapp.mobile"
                minSdkVersion 10
                targetSdkVersion 21
                testApplicationId "com.myapp"
                multiDexEnabled true
            

            buildTypes 
                release 
                    minifyEnabled true
                    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
                    signingConfig signingConfigs.release
                
            

            compileOptions 
                sourceCompatibility JavaVersion.VERSION_1_8
                targetCompatibility JavaVersion.VERSION_1_8
            
        

我的根 build.gradle 是

        apply plugin:'base'
        buildscript 
            repositories 
                jcenter()
                google()
            
            dependencies 
                classpath 'com.android.tools.build:gradle:3.0.0'
            
        

        allprojects 
            repositories 
                jcenter()
                google()
            
        

所以我使用了匹配的构建工具。我的问题的任何其他解决方案。

【问题讨论】:

您可能遗漏了一些日志。你发送到这里的日志之前是什么? Proguard 可能只是抱怨配置错误或没有从新库中找到类或其他东西,这很常见。但这是在日志中比您提供的更早的输出。 这(可能)不是与版本不匹配有关的“错误:任务执行失败:android:transformClassesAndResourcesWithProguardForRelease‌​”的副本。这个问题(可能)是一个很常见的通用 Proguard 配置问题。 请举个例子 【参考方案1】:

问题不在于 IOException。这是关于 Gradle 和 SDK 设置的。已经有一个非常相似的question。请检查这是否有帮助...

【讨论】:

但在我的情况下这些版本很好 android compileSdkVersion 26 buildToolsVersion "26.0.3" 和根文件夹中的依赖关系依赖项 classpath 'com.android.tools.build:gradle:3.0.1' 还有什么会导致这个问题? 您是否尝试过清理(Gradle clean)项目然后运行它? gradle --info --stacktrace --debug clean build 这个命令我已经运行了 在您的模块依赖项中,您使用的是 gradle 版本 com.android.tools.build:gradle:2.1.2,而在另一个依赖项中,您正在使用另一个依赖项 'com.android.tools.build:gradle:3.0.0'。将Java版本从7更改为8时是否出现此错误?

以上是关于在Android Studio终端中运行时出现IO异常[重复]的主要内容,如果未能解决你的问题,请参考以下文章

在终端中运行时找不到phpize命令[重复]

当命令在 Ubuntu 终端中运行时,为啥 Dart 的“Process.start”不能执行 Ubuntu 命令?

简单的 C# 应用程序无法正常工作,在 Visual Studio 中运行时工作正常

在visual studio 2008中运行时,表单不显示更改

在 Visual Studio 2010 调试器中运行时不会显示 Windows 公用文件对话框

应用未在 iO 中运行时的本地区域识别