Since I updated ADT from 16 to 18 (which mandated Proguard update from 4.6 to 4.8), Proguard has been acting very weirdly (and inconsistently?).
The latest such problem is when I try to export a signed (release) APK, I receive the following errors:
Proguard returned with error code 1. See console
Warning: com.bta.LibProj2: can't find referenced class com.bta.R$string
Warning: com.bta.MyDlg1: can't find referenced class com.bta.R$string
Warning: com.bta.MyMenu: can't find referenced class com.bta.R$menu
Warning: com.bta.R: can't find referenced class com.bta.R$attr
Warning: com.bta.R: can't find referenced class com.bta.R$drawable
Warning: com.bta.R: can't find referenced class com.bta.R$menu
Warning: com.bta.R: can't find referenced class com.bta.R$string
Warning: com.bta.myapp.MyAppActivity$1: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.MyAppActivity$ELicenseResponse: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback$1: can't find referenced class com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback
Warning: com.bta.myapp.MyAppActivity$MyLicenseCheckerCallback$1: can't find referenced class com.bta.myapp.MyAppActivity
Warning: com.bta.myapp.R$array: can't find referenced class com.bta.myapp.R
Warning: com.bta.myapp.R$layout: can't find referenced class com.bta.myapp.R
Warning: com.bta.myapp.R$xml: can't find referenced class com.bta.myapp.R
Warning: there were 49 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:212)
at proguard.ProGuard.execute(ProGuard.java:87)
at proguard.ProGuard.main(ProGuard.java:493)
I did notice the recommendation to add -libraryjars
in proguard.cfg, but I never needed to do this before (and I didn't change anything in my code, all I did was updating Proguard from 4.6 to 4.8). Does this suggest something wrong in my development environment configuration?
Also, I checked Proguard's Troubleshooting section for Can't find referenced class: It refers to forgetting or ignoring to specify a library via -libraryjars
(which I admit), but I never specified any library and it always worked before! What changed?
My proguard.cfg file BTW starts with:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
Any idea what's going on? Why did Proguard start giving me such hard time? (I coasted very smoothly with it for over a year now) Is there something fundamental I am missing in my system configuration?
BTW, I did try to add the libraries I have been using by specifying all of them in -libraryjars
lines, but Proguard's behavior only got worse: It would fail without giving any of the error log that I quoted above.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…