Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安卓应用赢得';由于Android Studio中的Gradle问题,无法启动_Android_Android Studio_Android Gradle Plugin - Fatal编程技术网

安卓应用赢得';由于Android Studio中的Gradle问题,无法启动

安卓应用赢得';由于Android Studio中的Gradle问题,无法启动,android,android-studio,android-gradle-plugin,Android,Android Studio,Android Gradle Plugin,我正在尝试使用我的三星/虚拟机编译我的android项目,但我遇到以下错误: Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirt

我正在尝试使用我的三星/虚拟机编译我的android项目,但我遇到以下错误:

    Error:Execution failed for task ':app:dexDebug'.
    > com.android.ide.common.process.ProcessException:         
    org.gradle.process.internal.ExecException: Process 'command
    '/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java'' 
    finished with non-zero exit value 2

我在任何地方都找不到答案,有什么想法吗?

请尝试在您的gradle中启用多索引文件支持。

将以下代码添加到您的
build.gradle

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

据我所知,此错误与JDK或gradle本身无关,可能有许多原因,例如:

  • 超过65k方法限值。
  • 您可以尝试在gradle中启用多索引支持:

    defaultConfig {        
        // Enabling multidex support.
        multiDexEnabled true
    }
    
    或者只是尝试通过删除一些不必要的库来最小化应用程序

  • 一些jar或库文件包含在多个位置。
  • 对于此操作,请在Android Studio中运行以下命令:

    gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile
    
    在列出的依赖项(标有星号*)中搜索重复项并将其删除

    在问题中列出了更多的可能性

    classpath 'com.android.tools.build:gradle:1.3.0' -> Should be 1.3.1
    
    buildToolsVersion '23.0.0' -> Should be '23.0.2'
    
    还加

     defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
    
    }


    清理代码并重新构建

    您正在使用的库是什么?太棒了!但我的等级版本目前是1.1.0,我如何更新它?使用sdk管理器更新您的sdk。之后,您可以选择将其更改为最新版本。
    For me the problem was, i had put a unnecessary compile library code in build.gradle
    
    dependencies {
        compile 'com.google.android.gms:play-services:7.5.0'
    }
    which was causing over 65k methods, so removed it,gradle sync, cleaned project, and then ran again and then this error stopped. I needed just maps and gcm so i put these lines and synced project
    
    compile 'com.google.android.gms:play-services-gcm:7.5.0'
    compile 'com.google.android.gms:play-services-location:7.5.0'
    
    Hi people i again encountered this problem and this time it was because of changing build tools version and it really required me to enable multidex..so i added these my app's build.gradle file..
    
    defaultConfig {
        applicationId "com.am.android"
        minSdkVersion 13
        targetSdkVersion 23
        // Enabling multidex support.
        multiDexEnabled true
    }
    
    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
        jumboMode = true
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:multidex:1.0.1'
    }
    And create a class that extends Application class and include this method inside the class..
    
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
    also include in OnCreate method too
    
    @Override
    public void onCreate() {
        MultiDex.install(this);
        super.onCreate();
    }