2016-11-21 159 views
0

我想生成已簽名的apk。但我達到了64k的方法限制,所以我搜索了一些解決方案,其中一個是使用proguard。 我編輯的build.gradle這樣的:Android Proguard「找不到引用」

buildTypes { 

     release { 
      minifyEnabled true 
      shrinkResources true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 

    } 

當我再嘗試生成APK簽署我得到了很多的警告:

Warning:com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$2: can't find referenced method 'android.widget.TextView access$000(com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar)' in program class com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar 
Warning:com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$2: can't find enclosing method 'void setTextProgressAlign()' in program class com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar 
Warning:com.github.mikephil.charting.data.realm.base.RealmBarLineScatterCandleBubbleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmBarLineScatterCandleBubbleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.Sort 
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.Sort 
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmBaseDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineScatterCandleRadarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmLineScatterCandleRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.base.RealmUtils: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmList 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmList 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmList 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmList 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmList 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterData: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterData: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.DynamicRealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmObject 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmResults 
Warning:com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet: can't find referenced class io.realm.RealmObject 
Warning:there were 283 unresolved references to classes or interfaces. 
Warning:there were 2 unresolved references to program class members. 
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first. 
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForFreeRelease'. 
> java.io.IOException: Please correct the above warnings first. 

所以,問題似乎是我實現了資源庫。我讀過,我必須配置proguard-rules.pro文件,但我從來沒有使用過,並不知道語法。 我該如何解決這個問題?

EDIT 依賴關係:

compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.android.support:design:24.2.1' 
    compile 'com.android.support:recyclerview-v7:24.2.1' 
    compile 'com.android.support:cardview-v7:24.2.1' 
    compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1' 
    compile 'com.github.lzyzsd:circleprogress:[email protected]' 
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.3' 
    compile 'net.qiujuer.genius:ui:1.5.2' 
    compile 'com.akexorcist:RoundCornerProgressBar:2.0.3' 
    compile 'com.rengwuxian.materialedittext:library:2.1.4' 
    compile 'com.github.medyo:fancybuttons:1.8.1' 
    compile 'com.google.android.gms:play-services:9.6.1' 
    compile 'com.github.sundeepk:compact-calendar-view:1.9.3' 
+0

添加'build.gradle'的依賴部分。 –

+0

@R.Zagórski我做編輯 – XxGoliathusxX

+0

buildTypes { 發佈 調試的假 minifyEnabled假 proguardFiles getDefaultProguardFile( 'proguard的-android.txt'), 'proguard-rules.pro' } 調試{ 調試的真實 minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro' } } –

回答

3

有兩個問題的庫:

RoundCornerProgressBar

MPAndroidChart

第一個問題是與類com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar。有克服這個問題,通過向Proguard的一個解決方案here

-dontwarn com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar 

第二個是簡單地通過增加兩個語句解決了ProGuard的,該庫的作者清楚地描述here

-keep class com.github.mikephil.charting.** { *; } 
-dontwarn io.realm.** 

您的Proguard文件應該包含這些行,問題應該消失。

+0

非常感謝!所有警告消失!沒有你,我從來沒有發現過! – XxGoliathusxX

-1

buildTypes {

release { 
     debuggable false 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 


    debug { 
     debuggable true 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
+0

爲什麼minifyenabled在釋放false?我需要縮小我的apk – XxGoliathusxX

+0

標誌minifyEnabled保留ProGuard,並且默認關閉。因此,在默認設置下,調試和發佈版本都不使用ProGuard,並且參數proguardFiles被有效忽略。如果U需要使用proguard enable minifyEnabled true。 –

+0

但這並不能幫助我使警告消失! – XxGoliathusxX

相關問題