Android Studio - Gradle:任务'执行失败':Foo:dexDebug' - 但为什么?

时间:2013-08-29 16:49:05

标签: java android intellij-idea gradle android-studio

我收到此错误:

Gradle: Execution failed for task ':Foo:dexDebug'.

从2天开始!我尝试了很多解决方案......但没有什么工作正常!真的!需要帮忙 ! 我使用android Studio。 (IntelliJ IDEA)

对于以下三个目录

   FooProject [RootProject]
   |-gradle
   |-libraries
     |-facebook [library1]
       |-libs
          |-android-support-v4.jar
       |-res
          |-*.(drawable...)
       |-src
          |-*.java
       |-build.gradle
       |-AnroidManifest.xml
       |-facebook.iml
     |-foosdk [library2]
       |-res
          |-*.(drawable...)
       |-src
          |-*.java
       |-libs
          |-YouTubeAndroidPlayerApi.jar
       |-build.gradle
       |-AnroidManifest.xml
       |-foosdk.iml
   |-Foo [project for execution]
     |-libs
        |-commons-io-1.3.2.jar
        |-commons-lang3-3.1.jar
        |-jackson-core-asl-1.9.11.jar
        |-jackson-databind-2.1.4.jar
        |-jackson-mapper-asl-1.9.11.jar
        |-robospice-1.4.1-SNAPSHOT.jar
        |-robospice-cache-1.4.1-SNAPSHOT.jar
        |-robospice-spring-android-1.4.1-SNAPSHOT.jar
        |-spring-android-core-1.0.1.RELEASE.jar
        |-spring-android-rest-template-1.0.1.RELEASE.jar
        |-YouTubeAndroidPlayerApi.jar
     |-src
      |-main
        |-java
          |-*.java
        |-res
          |-*.(drawable...)
     |-build.gradle
     |-AnroidManifest.xml
     |-Foo.iml
   |-gradlew
   |-gradlew.bat
   |-local.properties
   |-settings.gradle
   |-RootProject.iml

我有我的settings.gradle

include ':libraries:facebook', :libraries:foosdk', ':foo'

对于文件“build.gradle”:

适用于library / facebook / build.gradle

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 16
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

适用于库/ foosdk / build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 16
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

适用于Foo / build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:13.0.0'

    compile project(':libraries:foosdk')
    compile project(':libraries:facebook')
    compile fileTree(dir: 'libs', include: '*.jar')
}



android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 16
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src/main/java']
            resources.srcDirs = ['src']
            res.srcDirs = ['src/main/res']
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您的Foo项目是在/ Foo或/ foo文件夹中(请注意大写)?您可能需要将包含'foo'更正为'Foo'?

如果不起作用,请粘贴Gradle版本的信息或调试输出。如果您正在运行AndroidStudio并且没有任何输出,请转到项目的根目录并运行gradlew.bat assembleDebug --info(在Wins上)或./gradlew assembleDebug --info(在Linux / Mac上)或--debug并将输出粘贴到此处,以便我们可以确切地看到出了什么问题。