gradle-android-scala-plugin icon indicating copy to clipboard operation
gradle-android-scala-plugin copied to clipboard

DexIndexException, DexException

Open stanch opened this issue 9 years ago • 5 comments

Hi,

I’m not very familiar with the plugin, but it seems that this would be the right place to ask about these exceptions (from https://groups.google.com/forum/#!topic/macroid/IIZ2iyie6h0):

This compiles fine in AndroidStudio but when I tried to run it (assembleDebug) I was getting the DexIndexException for too many methods. I tried enabling MultiDex (according to their wiki and android docs), but this just gave me a new exception:

DexException: Too many classes in --main-dex-list, main dex capacity exceeded

stanch avatar May 27 '15 09:05 stanch

+1, I'm having this too.

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:494)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:244)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

when running gradle dexDevDebug --info, and also when I try to run tests.

hermanbanken avatar May 29 '15 15:05 hermanbanken

My build.gradle looks like this. Lots of duplicate scala dependencies, cause some libraries conflict with versions 2.11.2, 2.11.4 and 2.11.6.

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:1.1.3"
        classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.4"
    }
}

repositories {
    jcenter()
    maven {
        url "https://jitpack.io"
    }
}

apply plugin: "com.android.application"
apply plugin: "jp.leafytree.android-scala"

android {
    compileSdkVersion "android-22"
    buildToolsVersion "22.0.1"

    defaultConfig {
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
    }

    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "2g"
    }

    packagingOptions{
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    productFlavors {
        dev {
            minSdkVersion 15
        }

        prod {
            minSdkVersion 8
        }
    }
}

dependencies {
    compile "com.android.support:multidex:1.0.1"
    compile "io.reactivex:rxscala_2.11:0.24.1"
    compile "io.reactivex:rxandroid:0.24.0"
    compile 'com.androidplot:androidplot-core:0.6.1'
    compile 'com.nitayjoffe.thirdparty.net.robowiki.knn:knn-benchmark:0.1'
    compile 'com.github.tavendo:AutobahnAndroid:v0.5.2'
    compile 'edu.emory.mathcs:JTransforms:2.4'

    androidTestCompile 'org.scalatest:scalatest_2.11:2.2.5'
    androidTestCompile 'org.mockito:mockito-all:1.10.19'
    androidTestCompile "com.android.support:multidex-instrumentation:1.0.1", { exclude module: "multidex" }

    // Correct scala libs:
    compile "com.typesafe.zinc:zinc:0.3.7"
    compile "org.scala-lang:scala-library:2.11.6"
    compile "org.scala-lang:scala-compiler:2.11.6"
    compile "org.scala-lang:scala-reflect:2.11.6"
    androidTestCompile "org.scala-lang:scala-library:2.11.6"
    androidTestCompile "org.scala-lang.modules:scala-xml_2.11:1.0.3"
    androidTestCompile "org.scala-lang:scala-compiler:2.11.6"
    androidTestCompile "org.scala-lang:scala-reflect:2.11.6"
}

tasks.withType(ScalaCompile) {
    scalaCompileOptions.useAnt = false
    scalaCompileOptions.deprecation = false
    scalaCompileOptions.additionalParameters = ["-feature"]
}

hermanbanken avatar May 29 '15 15:05 hermanbanken

I posted the original message in macroid's forums. My dependencies are much simpler than hermanbanken:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'org.scala-lang:scala-library:2.11.6'
    compile 'org.macroid:macroid_2.11:2.0.0-M4'
    compile 'com.noveogroup.android:android-logger:1.3.1'
    compile "com.android.support:multidex:1.0.1"
}

bj0 avatar Jun 02 '15 22:06 bj0

+1, I'm having this too... try doing http://blog.osom.info/2014/12/too-many-methods-in-main-dex.html

swhgoon avatar Jun 30 '15 03:06 swhgoon

I'm having this too

cmlocker avatar Dec 10 '16 04:12 cmlocker