nuggetbram nuggetbram - 3 months ago 16
Android Question

Getting .dex 64K error on a small app that works fine on a different PC

I've recently started a new Android Studio project on one PC (very barebones: 3

Activity
s, 1
Fragment
, all very basic at this stage), and uploaded it to Version Control System through Android Studio (I assume it will only add the necessary files).

When I checkout the project on a different PC, Android Studio recognizes it is a project, and offers to open it as one. The gradle build completes, but on attempting to run the app on a device or emulator, I get the old problem:


Error: The number of method references in a .dex file cannot exceed 64K.


The only dependency as such is the 'bluealliance spectrum color picker', which I have used in the past without issue. I would assume that it has built something wrong, but considering everything is identical to the original project I can't see how it's going wrong - or how it could possibly have >64K methods.

Below are the gradle files:

mobile build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "com.aetherum.timetableapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories {
maven {
url "http://github.com/wada811/Android-Material-Design-Colors/raw/master/repository/"
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.thebluealliance:spectrum:0.6.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:preference-v7:23.2.1'
compile 'com.android.support:preference-v14:23.2.1'
compile 'com.wada811:android-material-design-colors:2.0.0'
}


And the project build.gradle :

buildscript {

repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}


I have tried cleaning and rebuilding the project, as well as checking it out again from git. At this stage, as an inexperienced developer, I'm out of ideas.

Answer

The only dependency as such is the 'bluealliance spectrum color picker',

No, you have at least seven dependencies, not including any JARs that might be in libs/.

One of those dependencies is play-services. Unless you are using every single API in the Play Services SDK, you will be much better off using more granular dependencies (e.g., play-services-maps for Maps V2), to pull in only those bits of Play Services that you need.

BTW, you should change your 23.2.1 dependencies to 23.4.0, so all your Android Support Library dependencies are from the same version.