android studio - 带库项目的App无法汇编发布

时间:2014-04-02 18:15:34

标签: android proguard

以下是我的build.gradle: apply plugin:'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 14
        versionName "1.4"
    }

    signingConfigs {
        release {
            storeFile file("***")
            storePassword "***"
            keyAlias "***"
            keyPassword "***"
        }
    }
    buildTypes {
        release {
            runProguard true
            proguardFiles 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }
        debug{
            runProguard true
            proguardFiles 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
}

我想生成签名的apk.But当我尝试运行'gradle assembleRelease'时,我得到以下内容:

    Warning: com.actionbarsherlock.internal.ActionBarSherlockCompat: can't find refe
    renced class com.actionbarsherlock.BuildConfig
    Warning: there were 1 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#unresolved
    class)
   :education:proguardRelease FAILED

    FAILURE: Build failed with an exception.

当我将'-dontwarn com.actionbarsherlock。**'添加到proguard文件时,sherlock也会被混淆。怎么避免这个?

1 个答案:

答案 0 :(得分:0)

一般情况下,您只能在com.actionbarsherlock.BuildConfig上设置dontwarn,如下所示:

-dontwarn com.actionbarsherlock.BuildConfig