4

I have integrated some third-party source into my android project and I'm having trouble getting it to build with proguard enabled. The build is failing with this:

Warning: there were 123 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 201 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.

:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

There are MANY notes and warnings to sort through and I can't make heads or tails of it. I have tried adding --keep class example.package.** { *; } for everything that seems to be causing warnings, but it is still failing. Can anyone suggest a strategy for dealing with issues like this? For example, if I see this:

Warning: info.guardianproject.netcipher.client.MyDefaultClientConnectionOperator: can't find superclass or interface ch.boye.httpclientandroidlib.impl.conn.DefaultClientConnectionOperator

what should I do about it?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
rmp251
  • 5,018
  • 4
  • 34
  • 46
  • No clues at https://github.com/guardianproject/NetCipher/tree/master/sample-hurl – ban-geoengineering Oct 13 '16 at 17:56
  • To reproduce this issue, add `compile 'info.guardianproject.netcipher:netcipher:1.2'` to the app's **build.gradle** dependencies. Then `import info.guardianproject.netcipher.NetCipher;` in your code and `HttpsURLConnection con = NetCipher.getHttpsURLConnection(url);` – ban-geoengineering Oct 13 '16 at 18:03
  • @ban-geoengineering please checkout the answers below as well as these links: http://proguard.sourceforge.net/manual/troubleshooting.html https://github.com/krschultz/android-proguard-snippets – rmp251 Oct 14 '16 at 18:34

2 Answers2

3

Adding the following to your proguard-file will solve the compile problem:

-dontwarn info.guardianproject.netcipher.**

That said, you should read up on any ramifications that would come with this. Proguard is usually giving warnings for a good reason.

Tommie
  • 1,945
  • 2
  • 14
  • 23
3

The reason you get those warnings is that guardianproject messed up with dependencies. As you can see here NetCipher does not have any dependencies. And httpclientandroidlib is clearly an outern project. Inside Netcipher they have built the .jar library and not packaging it into their library. Unfortunately, httpclientandroidlib is not available through jcenter dependency.

There are two solutions:

  1. Proposed by @Tommie: add

    -dontwarn info.guardianproject.netcipher.**
    

    to you proguard-rules.pro file if those dependecies are not necessary. You just get rid of warning, sometimes it is a good way. But usually does not work. Then go to step two

  2. You need to add httpclientandroidlib manually to your project.

    1. Download a project from github as .zip

    2. Add new module to your project, name it httpclientandroidlib (name is arbitrary. I name it like that just for reference)

    3. Copy folder structure ch.boye.httpclientandroidlib to new module's src folder

    4. Replace module's AndroidManifest with the one from httpclientandroidlib library.

    5. Add dependecy to your main aa module:

      compile project(':httpclientandroidlib')
      

Then you can start working with the project.

Community
  • 1
  • 1
R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
  • Thanks for this. I'm running into the same problem after adding `compile 'com.madgag.spongycastle:prov:1.54.0.0'` to my app's build.gradle file. According to http://www.methodscount.com/?lib=com.madgag.spongycastle%3Aprov%3A1.54.0.0 , it has 1 dependency, so do you know how I can find out what that dependency is? – ban-geoengineering Oct 18 '16 at 16:01
  • Does [this solution](http://stackoverflow.com/a/29787286/6507689) does not work for you? – R. Zagórski Oct 19 '16 at 08:39
  • It works, thank you, hence the bounty being awarded to you. In my comment, I was asking a different question - about methodscount.com. – ban-geoengineering Oct 21 '16 at 13:04
  • 1
    Oh.. there is button "Dependency List". But is shows only dependencies, that were defined by `depencendies.compile` statement in `build.gradle` file. – R. Zagórski Oct 21 '16 at 13:07
  • Sorry, I didn't see the link in your previous message. Yes, that other solution has solved all my problems - seemingly because I was 'manually' including the jars in my libs folder and/or (more likely) because I had the **pg** dependency missing. All working perfectly now! :-) And, in case it helps anyone else, my **proguard-rules.pro** content is `-keep class org.spongycastle.** { *; } -dontwarn org.spongycastle.** -keepattributes Exceptions,Deprecated,EnclosingMethod -keep public class * {public protected *;}` – ban-geoengineering Oct 26 '16 at 19:00