2

i am trying to add firebase-messaging in my project where i am already using google maps. so when i add firebase dependecy

compile 'com.google.firebase:firebase-messaging:10.0.1'

i got following error.

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:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

how can i solve this issue here is my build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "23.0.1"

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.1.1'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:10.0.1'

compile 'com.android.support:cardview-v7:25.+'
compile 'org.lucasr.twowayview:twowayview:0.1.4'

}

these are google dependencies

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:10.0.1'
AL.
  • 36,815
  • 10
  • 142
  • 281
Sohail Yasin
  • 344
  • 1
  • 3
  • 16

3 Answers3

2

enable multidex in your default config.

defaultConfig {
    applicationId "com.edesign.astutesol.sallaticustomerapp"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
Nayan Srivastava
  • 3,655
  • 3
  • 27
  • 49
2

If enabling multidex support hasn't worked for you it can be because you might have defined custom application class for your app. What's the application name in your manifest file? If you have defined a custom application class by extending Application (say for example to integrate ACRA, or google analytics) then you will have to override attachBaseContext method.

@Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
Sudip Bhandari
  • 2,165
  • 1
  • 27
  • 26
1

short answer: remove compile 'com.google.android.gms:play-services:10.0.1'


You should not have the following line in your build.gradle

compile 'com.google.android.gms:play-services:10.0.1'

that line will include ALL the google libraries in your applications, which will exceed the method limit (the error you reported) and will make your app big without benefits.

You should include only the sub library that you need.

Example:

compile 'com.google.android.gms:play-services-auth:10.0.1

is ok because you are including only the -auth parth of the library.

Diego Giorgini
  • 12,489
  • 1
  • 47
  • 50