Skip to content

Compiling with ProGuard #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danepowell opened this issue Oct 7, 2016 · 14 comments
Closed

Compiling with ProGuard #533

danepowell opened this issue Oct 7, 2016 · 14 comments

Comments

@danepowell
Copy link

danepowell commented Oct 7, 2016

I'm having no luck trying to compile a project depending on Parse with ProGuard.

When I set minifyEnabled to true in the project, I get dozens of warnings related to OkHttp:

Warning:com.parse.ParseOkHttpClient: can't find referenced class okhttp3.OkHttpClient

My understanding is that these warnings should have been fixed in #414, as long as I'm using the AAR dependency, which I'm pretty sure I am (in app/build.gradle):

compile 'com.parse:parse-android:1.13.1@aar'

Oddly, even if I copy Parse's proguard rules to my own app, the warnings still show up.

I'm at a loss for how to continue debugging this. Can anyone help?

@lxknvlk
Copy link

lxknvlk commented Oct 7, 2016

Hm, im not sure but you can try adding this to your proguard-rules.pro:

-keep class okhttp3.** { *; }

or try this

-keep class okhttp3.**

Not an expert in proguard, but similar problems were fixed like this. As i understand these lines keeps proguard from obfuscating the specified classes.

I also have this in my proguard:

-keep class com.parse.* { ; }
-dontwarn com.parse.

@danepowell
Copy link
Author

Thanks, this was the only line I needed to add:

-dontwarn com.parse.*

I'm not sure why that would be. Parse shouldn't be throwing warnings in the first place, because all of those okhttp3 classes should be kept in, not sure why the keep statements don't work.

It would be nice to not have to write custom proguard rules just to build a basic Parse app, but thanks for the workaround.

@natario1
Copy link
Contributor

-dontwarn com.parse.ParseOkHttpClient is probably a better choice, so you will be warned about different issues that might arise in the future.

@danepowell
Copy link
Author

danepowell commented Oct 30, 2016

Yeah you'd think that would work, but what I'm saying is that ProGuard is defying all logic here... -dontwarn com.parse.ParseOkHttpClient produced a bunch of warnings like Warning:com.parse.ParseOkHttpClient$1: can't find referenced class okhttp3.Interceptor.

Only -dontwarn com.parse.* gets rid of these warnings.

And neither of these should be necessary in the first place, since Parse has a ProGuard file configured to keep those classes. 😕

@natario1
Copy link
Contributor

natario1 commented Oct 30, 2016

@danepowell try with -dontwarn com.parse.ParseOkHttpClient** then.

I have not read parse ProGuard file, but this is not about keeping. ProGuard can’t keep okhttp3 classes because you are not using okhttp3.

Internally, parse network interface can rely on different http libraries (Apache Http, OkHttp). Which library is used, it depends on which library is available. If you compile okhttp3, parse will use it and the warnings will disappear.

See https://github.com/ParsePlatform/Parse-SDK-Android/blob/master/Parse/src/main/java/com/parse/ParseHttpClient.java#L43 .

@lxknvlk
Copy link

lxknvlk commented Oct 30, 2016

There was somewhere here exact same issue, i remember answering it and it was fixed.

@danepowell
Copy link
Author

danepowell commented Oct 30, 2016

Thanks, -dontwarn com.parse.ParseOkHttpClient** works.

Your explanation makes sense. I'm almost certain that it's inconsequential, but I'm curious if there's a preferred HTTP library.

@rogerhu
Copy link
Contributor

rogerhu commented Mar 8, 2017

OkHttpClient is the preferred. Does the proguard rules just need to add -dontwarn com.parse.ParseOkHttpClient**?

@Jawnnypoo
Copy link
Member

@rogerhu This shouldn't be an issue in the next version since the SDK will have a hard dependency on Okhttp

@rogerhu
Copy link
Contributor

rogerhu commented Mar 9, 2017

thanks

@rogerhu rogerhu closed this as completed Mar 9, 2017
@danepowell
Copy link
Author

Thanks, can't wait to try it. It seems like Maven doesn't have the latest releases (1.13.2 or 1.13.3), does it need to be updated?

@rogerhu
Copy link
Contributor

rogerhu commented Mar 10, 2017

Waiting for Parse guys to help figure out how to release Maven staged deploys. It's up on Sonatype snapshots (even v1.14.1-SNAPSHOT which includes this OkHttp changes.) In the interim, can you try out v1.14.1-SNAPSHOT?

@rogerhu
Copy link
Contributor

rogerhu commented Mar 11, 2017

V1.13.3 should be out...Can you check out?

@danepowell
Copy link
Author

Seems to be working, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants