Android Studio:Gradle构建出现错误

5

我一直在使用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 秒

这是我的应用 gradle 文件:

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')
    }

请参见 https://dev59.com/mXzaa4cB1Zd3GeqPPWSk。 - matiash
4个回答

3

这个问题虽然有些陈旧,但对于Android Studio的新手程序员可能仍然有用。 因此,在我的情况下,通过从“构建菜单”中清理项目来解决了这个错误。


2

我不确定您是否发布了所有错误的文本,在我的情况下,最后会有非常有用的信息来解决这个问题。也许在您的情况下,问题是相同的。

所以,在我的情况下出现了依赖关系的问题。 在我的应用程序模块中,在 build.grale 中我使用了其他支持.v4的依赖项

在您的情况下:compile 'com.android.support:support-v4:19.1.0'

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

要解决此问题,只需删除 jar,并将与主应用程序模块相同的行添加到您的 Facebook build.gradle 文件中以导入支持库。

希望这能帮助您。


0
我在Ubuntu 16.04中遇到了这个问题,并想出了一个简单的解决方案:
在终端中键入sudo nautilus
现在进入根目录并递归更改权限为读取和写入以及创建和删除文件。您可以通过选项“更改封闭文件的权限”来完成此操作。

0

今天我遇到了同样的问题

当被合并的dex文件中包含超过65536个方法(或字符串)时,dex合并器会出现错误。我们可以通过添加以下代码来解决这个问题:

dexOptions { jumboMode = true }

在gradle文件中添加此代码,并确保将其添加到所有子项目中,否则可能无法正常工作。


谢谢,但我已经对我的问题进行了一些更正。 - sherin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接