Android studio:Gradle构建完成时出错

时间:2014-07-11 05:02:06

标签: android android-studio android-gradle android-volley build.gradle

我一直在使用Android Studio,我在尝试构建时遇到此错误。我无法继续。

这是Android Studio中的错误:

    Executing tasks: [:libraries:facebook:generateDebugSources, :library:generateDebugSources, :volley:generateDebugSources]

    Configuration on demand is an incubating feature.
    WARNING [Project: :volley] "testPackageName" is deprecated (and will soon stop working); change to "testApplicationId" instead
    :libraries:facebook:preBuild
    :libraries:facebook:preDebugBuild
    :libraries:facebook:checkDebugManifest
    :libraries:facebook:prepareDebugDependencies
    :libraries:facebook:compileDebugAidl UP-TO-DATE
    :libraries:facebook:compileDebugRenderscript UP-TO-DATE
    :libraries:facebook:generateDebugBuildConfig UP-TO-DATE
    :libraries:facebook:generateDebugAssets UP-TO-DATE
    :libraries:facebook:mergeDebugAssets UP-TO-DATE
    :libraries:facebook:generateDebugResValues UP-TO-DATE
    :libraries:facebook:generateDebugResources UP-TO-DATE
    :libraries:facebook:packageDebugResources UP-TO-DATE
    :libraries:facebook:processDebugManifest UP-TO-DATE
    :libraries:facebook:processDebugResources UP-TO-DATE
    :libraries:facebook:generateDebugSources UP-TO-DATE
    :library:preBuild
    :library:preDebugBuild
    :library:checkDebugManifest
    :library:prepareDebugDependencies
    :library:compileDebugAidl UP-TO-DATE
    :library:compileDebugRenderscript UP-TO-DATE
    :library:generateDebugBuildConfig UP-TO-DATE
    :library:generateDebugAssets UP-TO-DATE
    :library:mergeDebugAssets UP-TO-DATE
    :library:generateDebugResValues UP-TO-DATE
    :library:generateDebugResources UP-TO-DATE
    :library:packageDebugResources UP-TO-DATE
    :library:processDebugManifest UP-TO-DATE
    :library:processDebugResources UP-TO-DATE
    :library:generateDebugSources UP-TO-DATE
    :volley:preBuild
    :volley:preDebugBuild
    :volley:checkDebugManifest
    :volley:prepareDebugDependencies
    :volley:compileDebugAidl UP-TO-DATE
    :volley:compileDebugRenderscript UP-TO-DATE
    :volley:generateDebugBuildConfig UP-TO-DATE
    :volley:generateDebugAssets UP-TO-DATE
    :volley:mergeDebugAssets UP-TO-DATE
    :volley:generateDebugResValues UP-TO-DATE
    :volley:generateDebugResources UP-TO-DATE
    :volley:packageDebugResources UP-TO-DATE
    :volley:processDebugManifest UP-TO-DATE
    :volley:processDebugResources UP-TO-DATE
    :volley:generateDebugSources UP-TO-DATE

建立失败

总时间:2分钟7.494秒

这是我的应用程序:

build.gradle:

        apply plugin: 'android'

    android {
        compileSdkVersion 19
        buildToolsVersion '19.1.0'
        defaultConfig {
            minSdkVersion 11
            targetSdkVersion 19
            versionCode 1
            versionName '1.0'
        }
        signingConfigs {
            release {

            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }
        }
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/ASL2.0'
        }
        productFlavors {
        }
    }


    dependencies {
        compile 'com.android.support:support-v4:19.1.0'
        compile 'com.google.android.gms:play-services:5.0.77'
        compile 'com.android.support:appcompat-v7:+'
        compile 'com.makeramen:roundedimageview:1.2.4'
        compile 'com.nineoldandroids:library:2.4.0+'
        compile project(':libraries:facebook')
        compile project(':library')
        compile project(':stripe')
        compile project(':volley')
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/activation.jar')
        compile files('libs/mail.jar')
        compile files('libs/iprint.jar')
    }

3 个答案:

答案 0 :(得分:3)

此问题已陈旧但对Android Studio的新程序员可能有用, 所以我的案例中的这个错误通过从Build Menu中清除项目来解决。

答案 1 :(得分:1)

我不确定你是否发布了所有错误的文本,在我的情况下到底将是非常有用的信息来解决这个问题。也许在你的情况下,麻烦是一样的。

所以,在我的情况下是依赖的问题。 在 build.grale 的app模块中,我使用了其他依赖项来支持.v4

在你的情况下:编译'com.android.support:support-v4:19.1.0'

Facebook SDK使用 jar ,因此,support.v4被添加为jar。

要解决此问题,只需移除jar,然后将 Facebook build.gradle 文件添加到同一行,以导入支持库,就像在主应用模块上一样。

希望,这会对你有帮助。

答案 2 :(得分:0)

我今天遇到了同样的问题

当合并的dex文件具有超过65536个方法(或字符串)时,这是dex合并中的错误。我们可以通过添加

来解决这个问题

dexOptions {         jumboMode = true     }

在gradle文件中。不要忘记添加所有子项目,否则它可能无法正常工作。