1

I am trying to generate signed apk for release. But it is keep failing with following warning in message box :

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

I tried to solve this by adding -dontwarn and -dontnote in my proguard-rules.pro file. Few of the warnings have been gone but still getting error. I am not getting what exactly I have to do to solve these warnings and generate apk. This is what I am getting in message box :

Note: there were 6 references to unknown classes.
      You should check your configuration for typos.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 4 classes trying to access generic signatures using reflection.
      You should consider keeping the signature attributes
      (using '-keepattributes Signature').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 80 unkept descriptor classes in kept class members.
      You should consider explicitly keeping the mentioned classes
      (using '-keep').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 17 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 1 class casts of dynamically created class instances.
      You might consider explicitly keeping the mentioned classes and/or
      their implementations (using '-keep').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclasscast)
Note: there were 4 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Warning:there were 4 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:msapp_V_520:transformClassesAndResourcesWithProguardForRelease FAILED
Error:Execution failed for task ':msapp_V_520:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

proguard-rules.pro file

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\user\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}
-dontwarn com.nostra13.example.universalimageloader.**
-dontnote com.nostra13.example.universalimageloader.**
-dontwarn com.facbook.**
-dontnote com.facbook.**
-dontwarn com.ikimuhendis.ldrawer.**
-dontnote com.ikimuhendis.ldrawer.**
-dontwarn com.loadindicators.adrianlesniak.library.**
-dontnote com.loadindicators.adrianlesniak.library.**
-dontwarn com.handmark.pulltorefresh.library.**
-dontnote com.handmark.pulltorefresh.library.**
-dontwarn com.pullToRefresh.**

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' }
}

android {
    signingConfigs {
        config {
            storeFile file('keystorePath')
            storePassword 'xyz...'
            keyAlias 'xyz...'
            keyPassword 'somePwd'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId "com.example..."
        minSdkVersion 14
        targetSdkVersion 20
        useLibrary 'org.apache.http.legacy'
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
    dexOptions {
        incremental true
    }
    productFlavors {
    }
}

dependencies {
    compile project(':comnostra13exampleuniversalimageloaderHomeActivity')
    compile project(':nineoldandroid')
    compile project(':libraryActionbar')
    compile project(':pullToRefresh')
    compile project(':facebook')
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile files('libs/AF-Android-SDK-v2.3.1.19.jar')
    compile files('libs/classes.jar')
    compile files('libs/CleverTapAndroidSDK-v1-20150903.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile project(':LoadIndicatorLibrary')
    compile 'com.nispok:snackbar:2.11.+'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}
Ruchir
  • 1,086
  • 4
  • 24
  • 48
  • Try to clean all project! – Nirav Ranpara May 16 '16 at 05:11
  • @NiravRanpara tried that too..but still getting same warning message. – Ruchir May 16 '16 at 05:13
  • Please refer this [link](http://stackoverflow.com/a/33953133/2078074). Hope it helps you. – Dhruv May 16 '16 at 05:46
  • @DhruvVaishnav answer given by onkar and your link has same answer and I tried it. Also I was using buildToolsVersion 23.0.3 and plugin version 2.0.0 . so after changing this as suggested in answer, I am getting Unable to compute hash of classes-proguard\release\classes.jar – Ruchir May 16 '16 at 05:53

1 Answers1

0

This bug happens when the versions of SDK, Build Tools and Gradle Plugins doesn't match (in terms of compatibility). The solutions is to verify if you are using the latest versions of them. The gradle plugins are placed in the build.gradle file of the project. Other versions are in the build.gradle file of the module. For example, for SDK 23, you must use the Build Tools 23.0.1 and gradle plugins version 1.3.1.

Clean the project after changing settings. refer this question

Community
  • 1
  • 1
onkar
  • 4,427
  • 10
  • 52
  • 89