Android Studio无法解析getDefaultProguardFile

时间:2015-03-20 05:00:12

标签: android proguard

当我运行我的程序时,我没有遇到任何问题。当我尝试生成签名的apk时,我被告知getDefaultProguardFile无法解析。我怎样才能解决这个问题。这是代码。

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

这是被问到的堆栈跟踪

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

2 个答案:

答案 0 :(得分:7)

我遇到了同样的问题。请注意,在日志中,他们指向您转到http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember并在那里说:

  

如果您正在为Android开发而ProGuard抱怨它不能   找到仅在最近版本中可用的方法   Android运行时,您应该更改您的构建目标   project.properties文件或build.gradle文件到该最新版本。   您仍然可以指定不同的minSdkVersion和不同的   AndroidManifest.xml文件中的targetSdkVersion。

我更改了compileSdkVersion& targetSdkVersion从21到22,它起作用了。

答案 1 :(得分:0)

您可能必须使用此

替换buildtypes codepart
signingConfigs {
    release {
        storeFile file("release.keystore")
        storePassword "******"
        keyAlias "******"
        keyPassword "******"
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}