7

I was recently hit with a puzzling problem with no explanation that I somehow managed to solve.

The solution itself poses a problem for me because I don't understand it: It forces me to direct Proguard to ignore all warnings regarding my own application's package in its entirety.

-dontwarn com.bta.**

Aside from the troubling issue of having to ignore warnings about the most error-prone code in my development (most frequently changing code), I am puzzled by two questions:

  1. Why did this need suddenly showed up? (I never needed to do this before.)
  2. Why isn't this needed in other projects/applications that I develop?

I believe some new code or library that I introduced caused this (AdMob?) but what is the explanation for this? Why would a third party library force me to turn off warnings about my own application's resources?

What are the side effects of turning off warnings about my own application package entirely (like I did)?

Community
  • 1
  • 1
Regex Rookie
  • 10,432
  • 15
  • 54
  • 88
  • 1
    Are you using the latest Proguard configuration consisting of a standard part from the SDK and an application specific part in your own configuration file (see http://tools.android.com/recent/proguardimprovements)? – Codo Jun 13 '12 at 10:35
  • @Codo No. Thank you very much for providing this link! In my hectic and frantic development environment I sometimes miss a critical piece of documentation like this. Please post this as answer so that I can accept it. I haven't read the document yet but brief browsing suggests that this may indeed be the key to the solution of the mystery. +1. – Regex Rookie Jun 13 '12 at 10:58
  • 1
    I'm not sure this is the solution for your problem. Let us know when you have tried it. – Codo Jun 13 '12 at 11:45
  • @Codo You're right. I just tried to run the APK produced by the `-dontwarn com.bta.**` "fix" and it crashed with `ClassNotFoundException: com.bta.myapp.MyAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.bta.myapp.myapp-1.apk]`. What a nightmare. – Regex Rookie Jun 13 '12 at 16:04
  • @Codo I managed to fix the runtime crash problem by changing `com.bta.**` to `com.bta.myapp.MyAppActivity.R**` in the `-dontwarn` statement. I also happen to be using the latest [Proguard for Android](http://stackoverflow.com/questions/11020256/how-to-automatically-generate-proguard-android-txt) convention which seems to make no difference whatsoever. So the original questions remain. – Regex Rookie Jun 13 '12 at 18:04
  • 1
    Please remove the `-dontwarn`, run it again and add the error messages to your question. If the error messages are still the same as in the related question, then I wonder why you have two R classes, `com.bta.R` and `com.bta.myapp.R`. Does your project refer to library projects? – Codo Jun 13 '12 at 18:18
  • @Codo Yes, I did try removing the `-dontwarn` (even after I migrated completely, fixed all lint reported warnings and the app stopped crashing, essentially working perfectly). But removing the `-dontwarn` brought back the same exact error messages as before. I have two R classes because my app depends on a library project (that I've created). – Regex Rookie Jun 13 '12 at 18:40
  • 1
    Possibly, the problem is with your library project. If I'm not mistaken the R class of your library project would need to be merged with the R class of your app. But it doesn't seem to work correctly. However, I've never created a library project myself and don't know how to properly do it. – Codo Jun 13 '12 at 20:18
  • @Codo Yes, but that library project never posed any problem prior to updating to Proguard 4.8. It never required that `-dontwarn` in Proguard 4.6 and even 4.4. This is why I am asking the question. There must be some new (stricter?) requirements introduced in Progard 4.8 **related to this problem** and I would like to understand what they are. – Regex Rookie Jun 13 '12 at 22:09

1 Answers1

7

Answering my own question:

After wasting way too much time on debugging the very tools that are supposed to save me time, I discovered the source of the problem. It's a bug in the Android SDK tools. It is documented as have been solved in r17, but I am using the latest of today (June 18 2012) and it hasn't been solved! (see comment 24). Comment 25 also describes the workaround that allows me now to proceed with my actual development.

Bugs are fact of life in complex systems. But the fact that neither Proguard nor the build tools that feed input to Proguard could provide any helpful error message (in fact they did exactly the opposite), suggests something is broken in the "methodology" of the Android development tools recommended by Google.

Regex Rookie
  • 10,432
  • 15
  • 54
  • 88