当shrinkResources为true时,Android Proguard-构建失败

当shrinkResources为true时,Android Proguard-构建失败,android,proguard,android-proguard,Android,Proguard,Android Proguard,我正在尝试构建一个启用proguard的项目。如果我使用shrinkResources false,它可以正常工作,但当shrinkResources为true时,生成失败,并出现错误 Error:The string "--" is not permitted within comments. Error:Execution failed for task ':app:packageDebug'. > !directory.isDirectory() 我已经在整个项目中检查了字符串“-

我正在尝试构建一个启用proguard的项目。如果我使用shrinkResources false,它可以正常工作,但当shrinkResources为true时,生成失败,并出现错误

Error:The string "--" is not permitted within comments.
Error:Execution failed for task ':app:packageDebug'.
> !directory.isDirectory()
我已经在整个项目中检查了字符串“-”我没有在注释中找到字符串“-”。所以我不理解这个错误

这是我的档案

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.eightsquare.eremit"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:support-v13:$supportLibVersion"
    implementation "com.android.support:design:$supportLibVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibVersion"
    implementation "com.android.support:cardview-v7:$supportLibVersion"
    implementation "com.android.support:support-v4:$supportLibVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    //crashlytics
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }

    implementation "com.google.android.gms:play-services-vision:$firebase_version"

    //Android-Iconics
    implementation "com.mikepenz:iconics-core:2.8.8@aar"
    implementation 'com.mikepenz:google-material-typeface:3.0.1.1.original@aar'

    //Butterknife
    implementation "com.jakewharton:butterknife:8.8.1"
    kapt "com.jakewharton:butterknife-compiler:8.8.1"

    //saripaar validation library
    implementation 'com.mobsandgeeks:android-saripaar:2.0.3'

    //rootbeer for root checking
    implementation 'com.scottyab:rootbeer-lib:0.0.6'

    //kotpref
    implementation "com.chibatching.kotpref:kotpref:2.4.0"
    implementation "com.chibatching.kotpref:initializer:2.4.0" // optional
    implementation "com.chibatching.kotpref:enum-support:2.4.0" // optional
    implementation "com.chibatching.kotpref:gson-support:2.4.0" // optional
    implementation "com.chibatching.kotpref:livedata-support:2.4.0" // optional

    //encrypting kotpref
    implementation 'com.github.fly7632785:KotprefEncryptSupport:1.0.1'

    //afollestad/material-dialogs
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'

    //RippleView
    implementation 'com.github.traex.rippleeffect:ripple:1.3.1-OG'

    //for checking the current uploaded version on the Google Play
    implementation 'com.github.robohorse:gpversionchecker:1.4.0'

    //RxAndroid
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.0'

    //toasty
    implementation 'com.github.GrenderG:Toasty:1.2.5'

    //anko
    implementation "org.jetbrains.anko:anko:$anko_version"

    //picaso library
    implementation 'com.squareup.picasso:picasso:2.5.2'

    //image slider
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'

    //rx runtime permissions
    implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

    //circleimageview
    implementation 'com.makeramen:roundedimageview:2.3.0'

    //materialedittext
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'

    //for recyclerview swipe
    implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'

    //facebook login
    implementation('com.facebook.android:facebook-android-sdk:4.30.0') {
        exclude group: 'com.google.zxing'
    }

    //firebase
    implementation "com.google.firebase:firebase-auth:$firebase_version"
    implementation "com.google.android.gms:play-services-auth:$firebase_version"

    //firebase Cloud Messaging
    implementation "com.google.firebase:firebase-messaging:$firebase_version"

    //graph
    implementation 'com.jjoe64:graphview:4.2.1'

    //Material date time picker
    implementation 'com.wdullaer:materialdatetimepicker:3.3.0'

    //signature pad
    implementation 'com.github.gcacace:signature-pad:1.2.1'

    //RxAndroid
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.8'

    //retrofit 2
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"

    //retrofit http interceptor
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'

    //gson converter factory
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'com.google.code.gson:gson:2.8.2'

    //input masking
    implementation 'com.redmadrobot:inputmask:2.3.0'

    implementation project(':idm-imgproc-1.1.99.70')
    implementation project(':opencv_3.2')
    implementation project(':card.io-5.5.1')

    //rxbinding
    implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
    implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'

    //Multidex
    implementation 'com.android.support:multidex:1.0.1'
}


repositories {
    mavenCentral()
}


apply plugin: 'com.google.gms.google-services'
这是proguard-rules.pro文件- `

#在此处添加特定于项目的程序规则。
#您可以使用
#在build.gradle中设置proguardFiles。
#
#有关详细信息,请参阅
#   http://developer.android.com/guide/developing/tools/proguard.html
#如果您的项目使用带JS的WebView,请取消注释以下内容
#并为JavaScript接口指定完全限定的类名
#类别:
#-keepclassmembers类fqcn.of.javascript.interface.for.webview{
#公众*;
#}
#取消对此的注释以保留行号信息
#调试堆栈跟踪。
#-keepattributes源文件,LineNumberTable
#如果保留行号信息,请将其取消注释为
#隐藏原始源文件名。
#-重命名SourceFileAttribute源文件
-优化过程5
#在不区分大小写的归档系统(如Windows)中不预先验证时。由于此工具将解压处理过的JAR,因此您应该使用:
-dontusemixedcaseclassnames
#指定不忽略非公共库类。从版本4.5开始,这是默认设置
-DontskipnonPublicLibraryClass
#预验证与dex编译器和Dalvik VM无关,因此我们可以使用-dontpreverify选项将其关闭。
-不要翻转
#指定在处理过程中写出更多信息。如果程序以异常终止,此选项将打印出整个堆栈跟踪,而不仅仅是异常消息。
-冗长的
#-optimizations选项禁用Dalvik 1.0和1.5无法处理的一些算术简化。请注意,Dalvik VM也不能处理(静态字段的)主动重载。
#了解或更改此支票http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-优化!代码/简化/算术,!字段/*,!类/合并/*
#在单个包上重新打包类
#-重新打包类“”
#如果使用注释保留注释,请取消注释。
-keepattributes*注释*
#保留AndroidManifest上引用的类
-keep public class*扩展android.app.Activity
-keep public class*扩展android.app.Application
-keep public class*扩展了android.app.Service
-keep public class*扩展了android.content.BroadcastReceiver
-keep public class*扩展了android.content.ContentProvider
-保持公共类com.android.vending.licensing.ILicensingService
#要删除调试日志,请执行以下操作:
-assumenosideeffects类android.util.Log{
公共静态***d(…);
公共静态***v(…);
}
#维护java本机方法
-KeepClassSwithMemberNames类*{
本地人;
}
#维护在XML布局上使用的自定义组件名称。
#如果对下面的方法有任何问题,请取消注释
#-保留公共类custom.components.package.and.name**
#要维护在XML布局上使用的自定义组件名称,请执行以下操作:
-keep public class*扩展了android.view.view{
public(android.content.Context);
public(android.content.Context、android.util.AttributeSet);
public(android.content.Context,android.util.AttributeSet,int);
公共无效集*(…);
}
-keepclassswithmembers类*{
public(android.content.Context、android.util.AttributeSet);
}
-keepclassswithmembers类*{
public(android.content.Context,android.util.AttributeSet,int);
}
#维护枚举
-keepclassmembers枚举*{
公共静态**[]值();
公共静态**valueOf(java.lang.String);
}
#保留可打包类(序列化-反序列化通过意图发送的对象)
-keep class*实现android.os.Parcelable{
公开静态最终android.os.Parcelable$Creator*;
}
#保持安静
-keepclassmembers类**.R$*{
公共静态;
}
######通常不使用的附加选项
#保留回拨电话。如果使用任何注释,请取消注释
#http://proguard.sourceforge.net/index.html#/manual/examples.html#callback
#-保持类mypackage.MyCallbackClass{
#void myCallbackMethod(java.lang.String);
#}
#如果使用Serializable,则取消注释
-keepclassmembers类*实现java.io.Serializable{
私有静态final java.io.ObjectStreamField[]serialPersistentFields;
私有void writeObject(java.io.ObjectOutputStream);
私有void readObject(java.io.ObjectInputStream);
java.lang.Object WriterReplace();
java.lang.Object readResolve();
}
#黄油刀7
#-保持类butterknife.*{*;}
#-dontwarn butterknife,内部**
#-保持类**$$ViewBinder{*;}
#
#-KeepClassSwithMemberNames类*{
#@butterknife.*;
#}
#
#-KeepClassSwithMemberNames类*{
#@butterknife.*;
#}
#appcompat支持
-保持公共类android.support.v7.widget.*{*;}
-保留公共类android.support.v7.internal.widget.*{*;}
-保留公共类android.support.v7.internal.view.menu.*{*;}
#科特普雷夫
-keep class*扩展com.chibatching.kotpref.KotprefModel
-keep public class*扩展了android.support.v4.view.ActionProvider{
public(android.content.Context);
}
#设计支持
-dontwarn android.support.design**
-keep class android.support.design.*{*;}
-保留android.support.design接口。**{*;}
-保留公共类android.support.design.R$*{*;}
#改装2.X
## https://square.github.io/retrofit/ ##
-dontwarn 2**
-保持类2.*{*;}
-保留署名
-保留特例
-keepclassswithmembers类*{
@2.http.*;
}
#格森霍克酒店
-保持类com.google.gson.*{*;}
-保持类org.sqlite.*{*;}
-保持类org.sqlite.database.*{*;}
##GSON 2.2.4具体规则##
#Gson使用类fil中存储的泛型类型信息
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

#To repackage classes on a single package
#-repackageclasses ''

#Uncomment if using annotations to keep them.
-keepattributes *Annotation*

#Keep classes that are referenced on the AndroidManifest
-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 com.android.vending.licensing.ILicensingService


#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}



#Maintain java native methods
-keepclasseswithmembernames class * {
    native <methods>;
}

#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**

#To maintain custom components names that are used on layouts XML:
-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);
}

#Maintain enums
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

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

###### ADDITIONAL OPTIONS NOT USED NORMALLY

#To keep callback calls. Uncomment if using any
#http://proguard.sourceforge.net/index.html#/manual/examples.html#callback
#-keep class mypackage.MyCallbackClass {
#   void myCallbackMethod(java.lang.String);
#}

#Uncomment if using Serializable
-keepclassmembers class * implements java.io.Serializable {
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# ButterKnife 7
#-keep class butterknife.** { *; }
#-dontwarn butterknife.internal.**
#-keep class **$$ViewBinder { *; }
#
#-keepclasseswithmembernames class * {
#    @butterknife.* <fields>;
#}
#
#-keepclasseswithmembernames class * {
#    @butterknife.* <methods>;
#}

#appcompat support
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

#kotpref
-keep class * extends com.chibatching.kotpref.KotprefModel

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

#design support
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }


# Retrofit 2.X
## https://square.github.io/retrofit/ ##

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

#Gson & hawk
-keep class com.google.gson.** { *; }
-keep class org.sqlite.** { *; }
-keep class org.sqlite.database.** { *; }


## GSON 2.2.4 specific rules ##

# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

-keepattributes EnclosingMethod

# Gson specific classes
#-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }


# Application classes that will be serialized/deserialized over Gson
-keep class com.eightsquare.eremit.model.** { *; }


#saripaar
-keep class com.mobsandgeeks.saripaar.** {*;}
-keep @com.mobsandgeeks.saripaar.annotation.ValidateUsing class * {*;}

-keep class me.zhanghai.android.materialprogressbar.** { *; }

#proguard
-dontwarn com.squareup.okhttp.**

#jsoup rules
-keep public class org.jsoup.** {
    public *;
}


#apache
-dontnote android.net.http.*
-dontnote org.apache.http.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-keep class android.net.http.** { *; }
-dontwarn android.net.http.**
-dontnote org.apache.commons.codec.**

#Data bindings
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }

-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

#gson
-keep class com.google.**
-dontwarn com.google.**

#eremit package
-keep class com.eightsquare.eremit.model.** { *; }

# Keep the support library
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }


-keepattributes javax.xml.bind.annotation.*
-keepattributes javax.annotation.processing.*
-keepclassmembers class * extends java.lang.Enum { *; }
-keepclasseswithmembernames class android.**
-keepclasseswithmembernames interface android.**
-dontwarn android.databinding.**

#Android-Iconics
-keep class .R
-keep class **.R$* {
    <fields>;
}

#gpversionchecker
-keep public class org.jsoup.** {
public *;
}

# If you are using custom exceptions, add this line so that custom exception types are skipped during obfuscation:
-keep public class * extends java.lang.Exception

# For Fabric to properly de-obfuscate your crash reports, you need to remove this line from your ProGuard config:
#-printmapping mapping.txt

-dontwarn rx.**
-dontwarn okio.**

-keepattributes *Annotation*,EnclosingMethod,Signature
-dontwarn com.squareup.okhttp.**


-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe


-dontobfuscate
-dontoptimize
-keepnames class ** { *; }
-keepnames interface ** { *; }
-keepnames enum ** { *; }