代码之家  ›  专栏  ›  技术社区  ›  XxGoliathusxX

Android Proguard“找不到引用”

  •  0
  • XxGoliathusxX  · 技术社区  · 8 年前

    我想生成一个签名的apk。但我达到了64k方法的限制,所以我搜索了一些解决方案,其中之一是使用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规则。pro文件,但我以前从未使用过,也不知道语法。 我怎样才能解决这个问题?

    编辑 依赖关系:

    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:1.1.0@aar'
        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'
    
    2 回复  |  直到 8 年前
        1
  •  5
  •   R. Zagórski Krishnraj Anadkat    8 年前

    有两个有问题的库:

    RoundCornerProgressBar

    MPAndroidChart

    第一个问题是课堂 com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar here

    -dontwarn com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar
    

    第二个问题简单地通过向Proguard添加两个语句来解决,该库的作者清楚地描述了这两个语句 here :

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

    您的Proguard文件应该包含这些行,问题应该消失。

        2
  •  -1
  •   Srinivas Keerthiprakasam    8 年前

    建筑类型{

        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'
        }
    }