3

Hello friends I make project in android studio and I have following jar in my project see my build.gradle file

build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.pkg.name"
    minSdkVersion 15
    targetSdkVersion 22
    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:multidex:1.0.0'

compile 'com.android.support:appcompat-v7:22.2.1'
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/apache-mime4j-0.6.jar')
compile files('libs/gson-2.1.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/json_simple-1.1.jar')
compile 'com.google.android.gms:play-services:7.5.0'
}

When i run my project it gives me the following error:

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_25\bin\java.exe'' finished with non-zero exit value 2 

Here is my logcat:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library 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
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
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_25\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 1 mins 13.355 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
Jonny Henly
  • 4,023
  • 4
  • 26
  • 43

3 Answers3

0

"compile fileTree(dir: 'libs', include: ['*.jar'])" compile all that has jar extension on libs folder, so comment:

 dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
 compile 'com.android.support:appcompat-v7:22.2.1'
  //compile files('libs/achartengine-1.1.0.jar')
 // compile files('libs/apache-mime4j-0.6.jar')
  //compile files('libs/gson-2.1.jar')
  //compile files('libs/httpmime-4.0.1.jar')
 // compile files('libs/json_simple-1.1.jar')
 compile 'com.google.android.gms:play-services:7.5.0'
}
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • sasikumar:: i did it as per your answer but still getting same error –  Aug 24 '15 at 05:35
  • same error get which i mention in my question above –  Aug 24 '15 at 05:38
  • Bulid--->Rebuild project then try – sasikumar Aug 24 '15 at 05:43
  • i rebuilt project but still getting error check below link:[http://pastie.org/10371724](http://pastie.org/10371724) –  Aug 24 '15 at 05:55
  • I think there's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file: dexOptions { javaMaxHeapSize "4g" } – sasikumar Aug 24 '15 at 06:00
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/87738/discussion-between-sasikumar-and-user3547706). – sasikumar Aug 24 '15 at 06:01
  • I think there's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file: dexOptions { javaMaxHeapSize "4g" } – sasikumar Aug 24 '15 at 06:02
  • refer http://stackoverflow.com/questions/25013638/android-studio-google-jar-causing-gc-overhead-limit-exceeded-error – sasikumar Aug 24 '15 at 06:02
0

It occurs when the number of values resource is more than the max count allotted for the project. I have fixed this issue by deleting the resource in string.xml/value.xml etc. It is the solution, there no work around other this, I have found, when I faced this issue.

Anitha Manikandan
  • 1,160
  • 7
  • 19
0

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

It happens because your project has more than 65,536 methods.

Add the dependency for the MultiDex support library in your build.gradle

dependencies { 
   //... 
   compile 'com.android.support:multidex:1.0.0'  
}

Enable multi-dexing by setting the multiDexEnabled flag in the buildType or productFlavor section of your gradle configuration.

defaultConfig { 
   //... 
   multiDexEnabled true 
}

In your AndroidManifest.xml

In your AndroidManifest.xml, simply declare android.support.multidex.MultiDexApplication as your application:

<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

If your app uses extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex.

Here you can find a official link to MultiDex Support Library

Here you can find a very detailed post about the topic.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841