Proguard Android Studio中的错误,无法使用minifyenabled来构建我的项目true

时间:2019-02-20 11:16:29

标签: android proguard

我正在使用 android studio 3.1.3 , 用proguard生成签名的APK时出现以下错误

Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to realm-android-library-object-server.aar (io.realm:realm-android-library-object-server:5.8.0)  1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to material-ripple.aar (com.balysv:material-ripple:1.0.2)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to dexter.aar (com.karumi:dexter:5.0.0)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to carousel.aar (com.azoft.carousellayoutmanager:carousel:1.2.4) 1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to recyclerview-v7.aar (com.android.support:recyclerview-v7:27.1.1)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to recyclerview-v7.aar (com.android.support:recyclerview-v7:27.1.1)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to RippleEffect.aar (com.github.emanzanoaxa:RippleEffect:52ea2a0ab6) 1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to recyclerview-v7.aar (com.android.support:recyclerview-v7:27.1.1)  1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to recyclerview-v7.aar (com.android.support:recyclerview-v7:27.1.1)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to cardview-v7.aar (com.android.support:cardview-v7:27.1.1)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to md-toast.aar (com.valdesekamdem.library:md-toast:0.9.0)   
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to number-picker.aar (com.shawnlin:number-picker:2.4.4)  1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to appcompat-v7.aar (com.android.support:appcompat-v7:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to appcompat-v7.aar (com.android.support:appcompat-v7:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to appcompat-v7.aar (com.android.support:appcompat-v7:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to appcompat-v7.aar (com.android.support:appcompat-v7:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to android-pdf-viewer.aar (com.github.barteksc:android-pdf-viewer:3.1.0-beta.1)  
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to pdfium-android.aar (com.github.barteksc:pdfium-android:1.9.0) 
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to support-v4.aar (com.android.support:support-v4:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to support-v4.aar (com.android.support:support-v4:27.1.1)    1ms
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to support-v4.aar (com.android.support:support-v4:27.1.1)    
Apply org.gradle.api.internal.artifacts.transform.VariantAttributeMatchingCache$1@293fc229 to support-v4.aar (com.android.support:support-v4:27.1.1)

我已将我的代码和错误放在以下链接中

https://pastebin.com/JGDaGz5D

和我的proguard文件

https://pastebin.com/6LgFX14J

2 个答案:

答案 0 :(得分:0)

如果您正在使用领域,请尝试将其添加到proguard文件中。

-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class *
-keep class sun.misc.*
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-keep class cz.msebera.android.httpclient.** { *; }
-keep class com.loopj.android.http.** { *; }

-dontwarn javax.**
-dontwarn io.realm.**
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient

答案 1 :(得分:0)

将此代码放入您的progard文件

 # Proguard Configuration for Realm (http://realm.io)
    # For detailed discussion see: https://groups.google.com/forum/#!topic/realm-java/umqKCc50JGU
    # Additionally you need to keep your Realm Model classes as well
    # For example:
    # -keep class com.yourcompany.realm.** { *; }

-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class *
-dontwarn javax.**
-dontwarn io.realm.*
-keep class cz.msebera.android.httpclient.** { *; }
-keep class com.loopj.android.http.** { *; }

*