Android Studio:Gradle 构建完成但出现错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24690388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:35:44  来源:igfitidea点击:

Android studio: Gradle build finished with error

androidandroid-studioandroid-gradle-pluginandroid-volleybuild.gradle

提问by sherin

I have been using Android Studio and I am getting this error when trying to build.I can't able to proceed.

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

This is the error in 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

BUILD FAILED

构建失败

Total time: 2 mins 7.494 secs

总时间:2 分 7.494 秒

This is my app gradle :

这是我的应用程序gradle:

build.gradle :

构建.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')
    }

回答by user5574803

This Question is old but it may be useful for new programmers of Android Studio , So this error in my case solved by cleaning project from Build Menu.

这个问题很老,但它可能对 Android Studio 的新程序员有用,所以在我的情况下这个错误通过从 Build Menu 中清除项目来解决。

回答by Volodymyr Yatsykiv

I'm not sure if you post all error's text, in my case in the end will be very useful information to fix this trouble. Maybe in your case trouble is the same.

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

So, in my case was trouble with dependecies. In my app module in build.graleI used other dependencies for support.v4

所以,就我而言,依赖关系有问题。在build.grale 的应用程序模块中,我使用了 support.v4 的其他依赖项

In your case: compile 'com.android.support:support-v4:19.1.0'

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

Facebook SDK used jar, so, support.v4 was added as jar.

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

To fix this, just remove jar, and add to your Facebookbuild.gradlefile the same line to import support library as on your main app module.

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

Hope, this will help you.

希望能帮到你。

回答by Apoorv Agarwal

I faced this problem in ubuntu 16.04 and came up with a simple solution:

我在 ubuntu 16.04 中遇到了这个问题,并想出了一个简单的解决方案:

Type sudo nautilusin terminal.

输入sudo nautilus端子。

Now go to the root directory and recursively change permissions to Read and Write and Create and Delete files. You will be able to do that by the option Change permissions for enclosed files.

现在转到根目录并递归更改读取和写入以及创建和删除文件的权限。您可以通过更改封闭文件的权限选项来做到这一点。

回答by San

I faced same issue today

我今天遇到了同样的问题

This is a bug in dex merger when the dex files that are being merged have more than 65536 methods (or strings). We can fix this by adding

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

dexOptions { jumboMode = true }

dexOptions { jumboMode = true }

In the gradle file. Don't forget to add this all sub projects too else it may not work.

在 gradle 文件中。不要忘记添加所有子项目,否则它可能不起作用。