Skip to content
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

How to configure Proguard for Android Client library #160

Closed
gerritbeuze opened this issue Aug 24, 2018 · 5 comments
Closed

How to configure Proguard for Android Client library #160

gerritbeuze opened this issue Aug 24, 2018 · 5 comments

Comments

@gerritbeuze
Copy link

Hi,
I’m using the Nextcloud Android library to add Nextcloud support to an android app using Android Studio. I’m having trouble configuring Proguard. When I run with minifyEnabled false all is fine, but with minifyEnabled true I get lots of Proguard related warnings and error. For example:

com.owncloud.android.lib.common.ExternalLink$$Parcelable: can’t find superclass or interface org.parceler.ParcelWrapper

library class org.apache.commons.codec.binary.BinaryCodec extends or implements program class org.apache.commons.codec.BinaryDecoder

org.apache.jackrabbit.webdav.server.AbstractWebdavServlet: can’t find referenced method ‘int getContentLength()’ in program class org.apache.jackrabbit.webdav.WebdavRequest

I can run with disabling the warings , for example
-dontwarn com.owncloud.android.lib.**
etc.
But then the app crashes as soon as a client completes.

I have tried copying the Proguard.cfg settings from the Nextcloud client app on Github, but that does not make a difference.

Any idea how to configure Proguard to make this work?

Thanks in advance,

Gerrit Beuze

@gerritbeuze
Copy link
Author

In case anyone else stumbles upon this, here's a section of the Proguard config that makes it work in my case. Note: the -keep,allowshrinking is required, just ignoring the warnings was not enough.

# Nextcloud
-keep,allowshrinking class com.owncloud.android.** { *; }
-keep,allowshrinking class org.apache.jackrabbit.webdav.** { *; }
-keep,allowshrinking class org.apache.commons.codec.** { *; }
-keep,allowshrinking class org.apache.commons.logging.** { *; }
-keep,allowshrinking class org.parceler.** { *; }
-keep,allowshrinking class org.slf4j.** { *; }

#ignore nextcloud related warnings
-dontwarn com.owncloud.android.lib.**
-dontwarn org.apache.jackrabbit.webdav.**
-dontwarn org.apache.commons.codec.**
-dontwarn org.apache.commons.logging.**
-dontwarn org.slf4j.**

-dontskipnonpubliclibraryclasses

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepattributes InnerClasses
#end nextcloud

@AndyScherzinger
Copy link
Member

@tobiasKaminsky what do you think? I'd say it'd be nice to have this in the lib's documentation :)

@tobiasKaminsky
Copy link
Member

We have not enabled proguard on client app.
I am not sure if the setting there is working at all….

Until we have a good reason to use proguard, I would rather remove it completely.
(People need to use it, can still find this issue)

@AndyScherzinger
Copy link
Member

Okay, fine by me

@tobiasKaminsky
Copy link
Member

Then I'll close this, but as said, it can still be found via search.

tobiasKaminsky added a commit to nextcloud/android that referenced this issue Sep 12, 2018
As discussed in nextcloud/android-library#160 proguard.cfg is not correctly working.
As we do not use it, this should be removed.
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

3 participants