使用proguard生成APK时出错

时间:2015-01-10 08:26:06

标签: android proguard

我在启用progurd时遇到错误。请协助 错误:任务':app:proguardRelease'。

的执行失败
  

java.io.IOException:无法读取[/ root / AndroidStudioProjects / ChurchOfChristHymns / app / bin / classes](没有这样的文件或目录)

我试图运行gradlew assembleRelease,仍然无法正常工作

buld.gradle file look like this :
apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.root.churchofchristhymns"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.0.0'
}

我的progurd-rules.txt看起来像这样:

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
   public void *(android.view.View);
   public void *(android.view.MenuItem);
}

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

1 个答案:

答案 0 :(得分:0)

更改此内容

buildTypes {         发布 {             runProguard是的             proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt'         }     }

buildTypes {         发布 {             minifyEnabled是的             proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard- rules.txt'         }     }