1

I am able to run my app when i change to debug mode but it fails when i switch to release mode.

Error:

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. java.io.IOException: Please correct the above warnings first.

-

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.application.app"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
    }
}

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
}

dependencies {
compile 'com.sromku:simple-storage:1.2.0'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile project(':yandexmapkitlibrary')
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile 'com.google.code.gson:gson:2.6.2'

compile 'com.github.bumptech.glide:glide:3.7.0'
}

EDIT: As you can see the multidex is enabled in my build.gradle file.

EDIT 2:

App.java

public class App extends MultiDexApplication {

public static GoogleAnalytics analytics;
public static Tracker tracker;

@Override
public void onCreate() {
    super.onCreate();
    MultiDex.install(this);

    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800);
    tracker = analytics.newTracker("myAnalyticsId");
    tracker.enableExceptionReporting(true);
    tracker.enableAdvertisingIdCollection(true);
}

}

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.application.app" android:installLocation="preferExternal">

<!--permissions-->

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:logo="@mipmap/ic_launcher"
    android:name="android.support.multidex.MultiDexApplication"
    android:theme="@style/AppTheme">

<!--...-->

</application>
</manifest>
  • Possible duplicate of [Android : app loading library at runtime on Lollipop but not IceCreamSandwich](http://stackoverflow.com/questions/32407985/android-app-loading-library-at-runtime-on-lollipop-but-not-icecreamsandwich) – Devrim Jun 17 '16 at 10:37
  • @DevrimTuncer As you can see the multidex is enabled in my build.gradle file. – John Edward Jun 17 '16 at 10:40
  • What about your manifest and application class? Please check the answer at the link I've shared. – Devrim Jun 17 '16 at 10:42
  • remove this line, it is already included in play-services.-> compile 'com.google.android.gms:play-services-analytics:9.0.2' – Vivek Sinha Jun 17 '16 at 10:54
  • 1
    If it is saying **Please correct the above warnings first.** What are that warnings ?? – Janki Gadhiya Jun 17 '16 at 11:24
  • Since, you have set minifyEnabled to true for release build, you need to configure Proguard for the project. Please see the Proguard related documentation for various libraries you have used. – Chebyr Jun 17 '16 at 11:31

1 Answers1

2

the problem is in using com.google.android.gms:play-services:9.0.2 instead of using all google play services try to to use just what you need

and yes you are using

compile 'com.google.android.gms:play-services-analytics:9.0.2'

and then

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

the play-services-analytics:9.0.2 is included in play-services:9.0.2

just remove

com.google.android.gms:play-services:9.0.2
ekad
  • 13,718
  • 26
  • 42
  • 44
Raafat Alhmidi
  • 880
  • 9
  • 17