3

When I run my program i get no problems. When I try to generate signed apk, I am told that getDefaultProguardFile cannot be resolved. How can I fix this. Here is the code.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.dose.apps.brainnoodles"
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 13
        versionName "2.13"
    }
    buildTypes {
        release {
            //apply plugin: 'idea'
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile files('libs/InMobi-4.5.3.jar')
}

Here's the stacktrace that was asked

Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'void setTraversalAfter(android.view.View,int)' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:android.support.v4.media.session.MediaSessionCompatApi22: can't find referenced method 'void setRatingType(int)' in library class android.media.session.MediaSession
Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'android.view.accessibility.AccessibilityNodeInfo getTraversalBefore()' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:com.inmobi.commons.internal.ActivityRecognitionManager: can't find referenced class com.google.android.gms.common.GooglePlayServicesUtil
Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'void setTraversalAfter(android.view.View)' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'android.view.accessibility.AccessibilityNodeInfo getTraversalAfter()' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'void setTraversalBefore(android.view.View)' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:android.support.v4.view.accessibility.AccessibilityNodeInfoCompatApi22: can't find referenced method 'void setTraversalBefore(android.view.View,int)' in library class android.view.accessibility.AccessibilityNodeInfo
Warning:com.inmobi.commons.internal.ActivityRecognitionManager$a: can't find referenced class com.google.android.gms.common.GooglePlayServicesUtil
         You may need to add missing library jars or update their versions.
Warning:there were 6 unresolved references to classes or interfaces.
Warning:com.inmobi.commons.uid.a: can't find referenced class com.google.android.gms.common.GooglePlayServicesUtil
         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:there were 7 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:app:proguardRelease FAILED
Error:Execution failed for task ':app:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
That Thatson
  • 309
  • 1
  • 2
  • 16

3 Answers3

7

I had the same problem. Note that in the log they are pointing you to go to http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember and there it says:

If you're developing for Android and ProGuard complains that it can't find a method that is only available in a recent version of the Android run-time, you should change the build target in your project.properties file or build.gradle file to that recent version. You can still specify a different minSdkVersion and a different targetSdkVersion in your AndroidManifest.xml file.

I changed the compileSdkVersion & targetSdkVersion from 21 to 22 and it worked.

null
  • 1,178
  • 8
  • 15
  • 1
    @ThatThatson if this or any answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Sufian Apr 30 '15 at 07:20
1

@That Thatson :

Just update your buildTypes instead your . Try this way.

buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

You might have to replace the buildtypes codepart with this

signingConfigs {
    release {
        storeFile file("release.keystore")
        storePassword "******"
        keyAlias "******"
        keyPassword "******"
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}
Brad
  • 161
  • 1
  • 1
  • 8