Reputation: 4080
Adding
implementation 'com.google.firebase:firebase-core:11.8.0'
to my module gradle file gives me errors suggesting I have over 64K methods in my project.
My guess is that I'm somehow implement the whole google play services, although adding
implementation 'com.google.android.gms:play-services-maps:11.8.0'
or
implementation 'com.google.android.gms:play-services-location:11.8.0'
give me no errors.
Gradel:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "se.workshop.collect"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation "com.android.support:recyclerview-v7:26.1.0" //Recycler View Support
implementation "com.android.support:cardview-v7:26.1.0" //Recycler View Support
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.0"
implementation 'com.karumi:dexter:4.2.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version:"$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
and the errors:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Error:com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Error: at com.android.dx.merge.DexMerger$8.updateIndex(DexMerger.java:565)
Error: at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
Error: at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:574)
Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:166)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Information:BUILD FAILED in 13s
Upvotes: 1
Views: 639
Reputation: 317750
The simple answer to the question stated in the subject is that the dependency you added simply pushed the total number of methods above 64K, as you see in the error message. It sounds like you're assuming that it should not, but obviously it is. Bear in mind that firebase-core also brings in firebase-analyics and some other libraries, so you're actually getting more than just firebase-core when you add it.
In any event, you should enable multidex in your builds to prevent this error as you add more libraries.
Upvotes: 3