简体   繁体   English

Android Studio Gradle错误:使用离子库什库执行任务':app:dexDebug'的执行失败

[英]Android Studio Gradle Error:Execution failed for task ':app:dexDebug' using Ion koush lib

I want to use the Ion Lib from koush in Android Studio. 我想在Android Studio中使用koush的Ion Lib。 But after I synchronize the libraries in my gradle file and try to run the application a strange error occurs. 但是,当我同步gradle文件中的库并尝试运行该应用程序后,会发生奇怪的错误。

My thought is that the Ion Lib does not accept the other libraries in my gradle file. 我的想法是,离子库不接受我的gradle文件中的其他库。

Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAdsLite902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIid902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTagmanager902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet902Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalytics902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAuth902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAuthCommon902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAuthModule902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommon902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseConfig902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCrash902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseDatabase902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseDatabaseConnection902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIid902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseMessaging902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseStorage902Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseStorageCommon902Library UP-TO-DATE
:app:prepareComKoushikduttaAsyncAndroidasync218Library UP-TO-DATE
:app:prepareComKoushikduttaIonIon218Library UP-TO-DATE
:app:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE
:app:prepareComSpecyciResidemenu16Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:packageAllDebugClassesForMultiDex UP-TO-DATE
:app:shrinkDebugMultiDexComponents UP-TO-DATE
:app:createDebugMainDexClassList UP-TO-DATE
:app:dexDebug
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
6 errors; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED

My Gradle file: 我的Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "sample.test.soft"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.specyci:residemenu:1.6+'
    compile 'com.koushikdutta.ion:ion:2.1.8'
    compile 'com.koushikdutta.async:androidasync:2.1.8'
}

In my gradle file I replaced the '+' of ion and androidasync with the version numbers. 在我的gradle文件中,我用版本号替换了ion和androidasync的“ +”号。

First Compile the build with 首先用编译

compile 'com.android.support:multidex:1.0.1' 编译'com.android.support:multidex:1.0.1'

compile 'com.google.android.gms:play-services:+' 编译'com.google.android.gms:play-services:+'

In Your AndroidManifest.xml add this lines android:name 在您的AndroidManifest.xml中添加以下行android:name

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:name="android.support.multidex.MultiDexApplication"
    >

And In your build.gradle also add 并且在您的build.gradle中还添加

dexOptions {
    //incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g"
}

From the log you have posted j ava.lang.OutOfMemoryError: GC overhead limit exceeded . 从日志中您已发布j ava.lang.OutOfMemoryError:超出了GC开销限制 It's seems your Android Studio ran out of memory. 看来您的Android Studio内存不足。

To raise the heap limit of the dexing operation add this to your android closure: 要提高dexing操作的堆限制,请将其添加到您的android闭包中:

dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }

This will solve all the GC overhead issues, and you can have substantially more dependencies. 这将解决所有GC开销问题,并且您可以拥有更多的依赖项。 and I have noted that you are compiling the entire services com.google.android.gms:play-services:9.0.2 from google play. 并且我注意到您正在从Google Play编译整个服务com.google.android.gms:play-services:9.0.2

Selectively compiling APIs into your executable 选择性地将API编译到可执行文件中

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. 在6.5之前的Google Play服务版本中,您必须将整个API包编译到您的应用中。 In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit. 在某些情况下,这样做会使将应用程序中的方法数量(包括框架API,库方法和您自己的代码)保持在65,536个限制以下变得更加困难。 From version 6.5, you can instead selectively compile Google Play service APIs into your app. 从6.5版开始,您可以选择将Google Play服务API编译到您的应用中。

Read this for further. 阅读进一步。

First clean project. 第一个清洁项目。 For me it worked when I removed the classpath of google play from dependencies and now it looks like this: 对我来说,当我从依赖项中删除Google play的类路径时,它起作用了,现在看起来像这样:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:任务&#39;:app:dexDebug&#39;...使用android studio执行失败 - Error:Execution failed for task ':app:dexDebug'… using android studio 使用新的Android Studio Project,任务&#39;:app:dexDebug&#39;的Gradle Execution失败 - Gradle Execution failed for task ':app:dexDebug' with new Android Studio Project Android Gradle错误-任务&#39;:app:dexDebug&#39;的执行失败 - Android Gradle Error - Execution failed for task ':app:dexDebug' Gradle错误 - 任务执行失败':app:dexDebug' - Gradle error - Execution failed for task ':app:dexDebug' Gradle错误:任务&#39;:app:dexDebug&#39;的执行失败。 - Gradle Error:Execution failed for task ':app:dexDebug'. 任务':app:dexDebug'Android Studio的执行失败 - Execution failed for task ':app:dexDebug' Android Studio 任务&#39;:app:dexDebug&#39;的执行失败-Android Studio - Execution failed for task ':app:dexDebug' - Android Studio Android Studio中的任务“:app:dexDebug”执行失败 - Execution failed for task ':app:dexDebug' in Android Studio 任务&#39;:app“ dexDebug的Android Studio执行失败 - Android Studio Execution failed for task ':app"dexDebug 错误显示Android Studio中的任务&#39;:app:dexDebug&#39;执行失败 - Error says Execution failed for task ':app:dexDebug' in android studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM