Android Studio : UNEXPECTED TOP-LEVEL EXCEPTION:

前端 未结 4 526
孤街浪徒
孤街浪徒 2021-01-07 06:08

How Can I solve this error

Error:Execution failed for task \':app:dexDebug\'. com.android.ide.common.process.ProcessException: org.gradle.process.i

相关标签:
4条回答
  • 2021-01-07 06:33

    Have you tried commenting out the following in your build.gradle:

    //compile fileTree(dir: 'libs', include: ['*.jar'])
    

    REFERENCE: https://code.google.com/p/android/issues/detail?id=161605

    0 讨论(0)
  • 2021-01-07 06:36

    Welcome. You are at the first step of Android gradle hell.

    1. Update your Android SDK components in SDK Manager to latest one including Extra > Google Repository (recommend to add almost all in Extra).

    2. Let's wash up your current file.

      • AndroidManifest.xml: Remove the <uses-sdk ... /> lines. It's redundant as gradle file already defines it.

      • Build.gradle: Comment all compile files('libs/xxxxxxx.jar') lines. The first line compile fileTree(dir: 'libs', include: ['*.jar']) will include all jar files in libs folder. And, use compile from maven repository not jar files in order to maintain your dependencies fresh.

    For example, SimpleXML has repository id as below. Place the code below of the compile fileTree(dir: 'libs', include: ['*.jar']) line and remove 'simple-xml-2.7.1.jar' file in libs folder.

    compile('org.simpleframework:simple-xml:2.7.1') {
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'
    }
    

    Likewise, find repository id of each jar file in your libs folder and replace it below of the compile fileTree(dir: 'libs', include: ['*.jar']) line one by one. Make only jar files which unable to find in maven repository remain in libs folder.

    Finally, remove proguardFiles line. You need to find and fix the problem in general condition, then apply progruard afterward.

    1. Set version of buildToolsVersion and compileSdkVersion to latest one.

    My recommendation of today is as below,
    (numbers may vary when someone will see this post in the future)

    android {
        compileSdkVersion 22
        buildToolsVersion '22.0.1'
    
        dexOptions {
            preDexLibraries = false
            javaMaxHeapSize "2g"
        }
        defaultConfig {
            ...
            multiDexEnabled = false
        }
        lintOptions {
            abortOnError false
            disable 'InvalidPackage'
        }
    
        ...
    }
    
    
    dependencies {
        compile 'com.android.support:appcompat-v7:22.1.1' // Do NOT use 22.2.0 even it is newer one. It reported to cause some problems with other dependencies.
        compile fileTree(dir: 'libs', include: '*.jar')
        compile('com.google.android.gms:play-services-gcm:7.5.+')
            {
                exclude module: 'support-v4'
            }
    } 
    
    1. command gradle assembleDebug again. (for Windows, gradlew assembleDebug)

    2. If failed again, try to find and fix dependencies version conflict issues one by one. You may see exclude module: ... in my code. These resolve the conflict issue. Detailed instruction is given at the link: https://stackoverflow.com/a/30649660/361100

    0 讨论(0)
  • 2021-01-07 06:46

    Amazingly this one worked for me

    defaultConfig {
    multiDexEnabled true
    }
    

    Source: Android Studio fails to debug with error org.gradle.process.internal.ExecException

    0 讨论(0)
  • 2021-01-07 06:46

    The same error occurred to me when I imported all the Google Play Services APIs, as you do with

    compile('com.google.android.gms:play-services:7.5.+')

    Try removing this line and import only the Services APIs that you need: Google Play Services Setup

    0 讨论(0)
提交回复
热议问题