I recently switched image loading libraries from Glide to Fresco and now I am unable to generate a signed apk.
I keep getting this error;
Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
My Application class extends MultidexApplication, and I have the proguard-fresco.pro file included in my build.gradle.
Prior to using Fresco, my project built successfully each time but now i can't generate a signed apk. How can I mitigate this and get my project to build?
My build.gradle file is as follows:
buildscript {
repositories {
mavenCentral();
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.1'
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.9.0"
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply plugin: 'newrelic'
apply plugin: 'me.tatarka.retrolambda'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/glomadrian/maven" }
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.app.android"
minSdkVersion 19
targetSdkVersion 26
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
versionCode 79
versionName "0.9.9"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
multiDexKeepProguard file("proguard.multidex.config")
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-fresco.pro'
}
}
retrolambda {
jvmArgs '-noverify'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.newrelic.agent.android:android-agent:5.9.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.google.android.exoplayer:exoplayer-core:r2.5.1'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.5.1'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.5.1'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.5.1'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'io.realm:android-adapters:2.1.0'
compile 'org.parceler:parceler-api:1.1.6'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.andrognito.kerningview:kerningview:1.0.0'
compile 'com.flurry.android:analytics:6.4.2'
compile 'com.amazonaws:aws-android-sdk-core:2.6.0'
compile 'com.amazonaws:aws-android-sdk-pinpoint:2.6.0'
compile 'com.amazonaws:aws-android-sdk-sns:2.6.0'
compile 'com.google.android.gms:play-services-gcm:11.2.0'
compile 'com.wdullaer:materialdatetimepicker:3.1.3'
testCompile 'junit:junit:4.12'
annotationProcessor 'org.parceler:parceler:1.1.5'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile "com.mixpanel.android:mixpanel-android:5.1.4"
compile 'com.mani:ThinDownloadManager:1.3.0'
compile 'com.google.android:flexbox:0.3.0-alpha3'
compile 'com.airbnb:deeplinkdispatch:3.1.0'
annotationProcessor 'com.airbnb:deeplinkdispatch-processor:3.1.0'
compile 'com.facebook.fresco:fresco:1.5.0'
compile 'jp.wasabeef:fresco-processors:2.1.0'
}
apply plugin: 'com.google.gms.google-services'
Related
After updating android studio and several dependencies i now get this error message
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzeg.class
this is my gradle file
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.firebase.firebase-perf'
android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "REMOVED_FOR_PRIVACY"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// compile 'com.firebaseui:firebase-ui:1.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:mediarouter-v7:26.0.2'
compile 'com.google.android.gms:play-services-location:11.2.0'
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-crash:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
compile 'com.google.firebase:firebase-perf:11.2.0'
compile 'com.firebaseui:firebase-ui-auth:2.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:design:26.0.2'
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:multidex:1.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I already tried Cleaning and Rebuilding the project but nothing seems to work
okay what seemed to actually work was replacing
'com.google.android.gms:play-services-location:11.2.0'
with
'com.google.android.gms:play-services:11.2.0'
Bump up your build tool version to:
buildToolsVersion "26.0.2"
And exclude Play Services from Facebook, for example
compile ('com.facebook.android:facebook-android-sdk:[4,5)'){
exclude group:"com.google.android.gms"
}
Can't run an android application due to below error of gradle .
Gradle DSL method not found : 'compile()'
Possible Causes :
The project XXXX may be using a version of Gradle that does not contain the method .
The build file may be missing a Gradle Plugin .
Please help how to resolve this .
EDIT :
File build.gradle
PFB my build.gradle file from project , most the file seems to be added in dependencies but why the issue cannot address the same .
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "xxxxxxxx"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'me.zhanghai.android.materialprogressbar:library:1.1.6'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.sa90.materialarcmenu:library:1.4.1'
compile files('libs/jxl.jar')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.github.clans:fab:1.6.4'
compile 'com.android.support:cardview-v7:23.4.0'
compile files('libs/acra-4.6.1.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.1#aar') {
transitive = true;
}
compile 'commons-codec:commons-codec:1.10'
compile "com.android.support:support-v4:+"
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
}
You have dependency in the project build.gradle, make sure to place it in the app/build.gradle.
For example in app/build.gradle
dependencies {
compile 'com.android.support:appcompat-v7:25.2.0'
}
So, I have read all the questions I could find on this site regarding this issue. I have also had a chat in comments with one of the developer with similar issue, who was able to solve it.
I dont have apt or annotationProcessor written any where in my gradle scripts.
I dont have the word android-apt written anywhere in my code. I even went ahead and checked out all the libraries. That were included in my project.
This is a really big problem and needs to be solved.
I am attaching the modified build.gradle below, Please suggest :
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
dexOptions {
jumboMode = true
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.legalimpurity.indiancourts"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
multiDexEnabled true
vectorDrawables.useSupportLibrary = true;
}
buildTypes {
release {
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
signingConfigs {
}
dataBinding {
enabled = true
}
}
//For Facebook i guess
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
def var = dependencies {
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-plus:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-identity:9.4.0'
// compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
compile('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.android.support:multidex:1.0.1'
// compile 'com.joanzapata.pdfview:android-pdfview:1.0.4#aar'
compile 'com.github.barteksc:android-pdf-viewer:2.4.0'
compile 'com.wdullaer:materialdatetimepicker:3.1.3'
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.android.volley:volley:1.0.0'
// compile 'com.facebook.android:facebook-android-sdk:4.6.0'
// compile 'com.satsuware.lib:usefulviews:2.3.6'
compile 'com.hkm:hkmprocessbuttons:1.2.4'
compile 'com.github.thorbenprimke:realm-searchview:0.9.6'
compile 'com.jakewharton:butterknife:8.5.1'
// compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.deano2390:MaterialShowcaseView:1.1.0'
// compile 'com.zaihuishou:expandablerecycleradapter-databinding:1.0.0'
// compile 'com.squareup.picasso:picasso:2.5.2'
// compile 'com.legalimpurity.expandablerecyclerview:expandable-recyclerview:1.0'
compile project(':agendacalendarview')
compile project(':expandablelibrary')
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.android.support:support-v4:25.+'
}
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'com.google.gms.google-services'
configurations.all {
resolutionStrategy {
force "com.android.support:support-annotations:25.2.0"
}
}
Older versions of Realm use android-apt. You should upgrade your realm-android plugin version.
Replace
classpath "io.realm:realm-gradle-plugin:1.2.0"
with
classpath "io.realm:realm-gradle-plugin:3.1.2"
and then apply plugin
apply plugin: 'realm-android'
I searched a lot for the issue but the only answer i could find is refactoring the code from onCreate to enable quick startup. But the problem looks different in my case.
I and my team member are working on same code synchronized through GITHUB,builds made by him opens in a flash and builds made by me takes more than 10 seconds to start up.
Another issue, his builds are of 90MB or so and my builds are just 30MB. App is anyway fully functional but the difference seen in startup time and build size is too huge.
I am not sure about his system configuration, but I use JAVA8 for compilation, SDK 24 and Gradle 2.10 for building the app.
Here is my gradle file
buildscript {
repositories {
jcenter()
/*flatDir {
dirs 'libs'
}*/
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//compile(name:'library-release', ext:'aar')
classpath 'io.realm:realm-gradle-plugin:0.88.0'
classpath 'io.fabric.tools:gradle:1.21.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
useLibrary 'org.apache.http.legacy'
dexOptions {
maxProcessCount 4 // this is the default value
javaMaxHeapSize "4g"
dexInProcess = false
}
defaultConfig {
applicationId "com.sample.app"
minSdkVersion 21
targetSdkVersion 24
versionCode 31
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
/*debug {
minifyEnabled true
useProguard false
}*/
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java']
}
robolectric {
java.srcDir file('src/test/java/')
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.twitter.sdk.android:twitter:1.9.0#aar') {
transitive = true;
}
testCompile 'org.robolectric:shadows-play-services:3.0'
testCompile 'org.robolectric:shadows-support-v4:3.0'
testCompile 'org.powermock:powermock-module-junit4:1.6.2'
testCompile 'org.powermock:powermock-module-junit4-rule:1.6.2'
testCompile 'org.powermock:powermock-api-mockito:1.6.2'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.2'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.assertj:assertj-core:1.7.0'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7#aar') {
transitive = true;
}
// compile(group: 'com.google.gms', name: 'google-services', version: '2.0.0-beta4', ext: 'pom')
//apply plugin: 'com.android.application'
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.coinbase.android:coinbase-android-sdk:1.0.1'
compile 'org.roboguice:roboguice:2.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.14'
compile 'com.sprylab.android.texturevideoview:texturevideoview:1.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services-ads:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
}
//put 'com.google.gms.google-services' plugin at the bottom
apply plugin: 'com.google.gms.google-services'
if it happens only in debug mode so you can try to disable the instant run
Preferences > Build,Execution,deployment>instant run
and there uncheck "Enable Instant Run..."
Error:(51) A problem occurred evaluating project ':app'.
Could not find method complie() for arguments [com.google.android.gms:play-services-gcm:7.5.0] on project ':app'.
How to fix this error?
Please have a look at build.gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "XYZ"
minSdkVersion 14
targetSdkVersion 22
versionCode 13
versionName "3.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.squareup.okio:okio:1.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.akexorcist:RoundCornerProgressBar:1.2.0'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'joda-time:joda-time:2.7'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
complie 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
}
Replace
complie 'com.google.android.gms:play-services-gcm:7.5.0'
with
compile 'com.google.android.gms:play-services-gcm:7.5.0'
The error is basically saying that gradle does not know what complie is.