This question has been asked a few times, but I have tried all of the answers and I still have a the same error.
Below is all my dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/itextpdf-5.3.2.jar')
compile 'com.androidadvance:topsnackbar:1.1.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:palette-v7:25.3.1'
compile 'com.google.android.gms:play-services-ads:11.6.0'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.anjlab.android.iab.v3:library:1.0.44'
compile project(':adcolony-sdk-3.1.2')
testCompile 'junit:junit:4.12'
}
According to the other questions it has something to do with my dependencies. This question has the exact same question. The first answer in that question is:
You are including all play services in your project. Only add those you want.
This is not the case as you can see above.
I also tried adding:
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
The above causes a new error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'
There is also a question about this and according to the answers I should
Build/Clean Project
I have tried all the answers and I still can't get this error to go away, is there perhaps something I'm overlooking? Any help will be greatly appriecieted.
I SOLVED THIS ISSUE
The problem what that I have reached the 64k method limit - More info.
Android app (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your own code. In the context of computer science, the term Kilo, K, denotes 1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'.
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
The main issue was that I was trying to add jar
files into my libs
folder, by doing so I reached the max method limit. After adding compile 'com.android.support:multidex:1.0.1'
and multiDexEnabled true
my issue is solved.
Thank you for the answers and comments.