Android Studio:Gradle 执行失败.原因:管道破裂 [英] Android Studio: Failed Gradle execution. Cause: Broken Pipe

查看:52
本文介绍了Android Studio:Gradle 执行失败.原因:管道破裂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在 android-studio 中构建/运行我的 android 项目时,我都会收到一个消息框说:Failed to complete Gradle execution.Cause: Broken pipe然后旧版本的应用程序开始运行我的设备.我试图清理该项目,但收到相同的消息.我在这里尝试了解决方案,但它没有没有帮助.我还尝试了此处的解决方案.我得到 gradlew compileDebug --stacktrace --info 命令的以下输出:

Whenever I build/run my android project in android-studio I get a message box saying: Failed to complete Gradle execution.Cause: Broken pipeand then the old version of the app starts running on my device. I tried to clean the project but I get the same message. I tried the solution here but it doesn't help. I also tried the solution here. I get the following output of the gradlew compileDebug --stacktrace --info command:

Task 'compileDebug' is ambiguous in root project 'Wifi'. Candidates are: 'compileDebugAidl', 'compileDebugJava', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugTestAidl', 'compileDebugTestJava', 'compileDebugTestNdk', 'compileDebugTestRenderscript'.

* Try:                      
Run gradlew tasks to get a list of available tasks. Run with --debug option to get more log output.

* Exception is:             
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in root project 'Wifi'. Candidates are: 'compileDebugAidl', 'compileDebugJava', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugTestAidl', 'compileDebugTestJava', 'compileDebugTestNdk', 'compileDebugTestRenderscript'.
        at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:69)

我一直收到同样的错误.有人可以帮忙吗?

I keep getting the same error. Can anyone please help?

我的build.gradle如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 15
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.pervysage.wifi"
        minSdkVersion 15
        targetSdkVersion 15
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

推荐答案

我遇到了类似的问题,但注意到当我将 Linux 笔记本电脑配置为路由器时出现了问题.这里的用例是,然后我将通过我的笔记本电脑路由我手机的 WiFi 流量,并在调试时嗅探 HTTP 请求.这似乎混淆了 gradle 和/或 android studio.

I've had a similar problem, but noticed the problem occurred when I configured my Linux laptop as a router. The use-case here is I would then route my phone's WiFi traffic via my laptop and sniff HTTP requests while debugging. This seemed to confuse gradle and/or android studio.

删除必要的 iptables 命令,killall -9 java 并重新启动 android studio 以解决问题.

Remove the necessary iptables commands, killall -9 java and restart android studio for the problem to go away.

导致问题的linux命令(这些和其他类似的命令都会导致问题):

The linux commands that cause the problem (these and other similar commands will cause the problem):

  1. iptables -t nat -A POSTROUTING -j 伪装
  2. echo 1 >/proc/sys/net/ipv4/ip_forward

在 linux 上,我只需执行以下操作:

On linux, I simply do the following:

  1. iptables -t nat -F
  2. echo 0 >/proc/sys/net/ipv4/ip_forward

请记住,上述解决方案可能会破坏您的防火墙,因此除非您知道自己在做什么,否则不要玩这些东西.

Bear in mind that the solution above may screw up your firewall so don't play with this stuff unless you know what you're doing.

这篇关于Android Studio:Gradle 执行失败.原因:管道破裂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆