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

Proguard Issue with merging Rx Libs #6

Closed
GensaGames opened this issue Oct 17, 2017 · 7 comments
Closed

Proguard Issue with merging Rx Libs #6

GensaGames opened this issue Oct 17, 2017 · 7 comments
Assignees
Labels

Comments

@GensaGames
Copy link

GensaGames commented Oct 17, 2017

Tested on version 0.1.0 everything works Ok. After integration new 0.2.2 version faced with Proguard Issue below. Clean Gfycat Sample works Ok.

Got an uncaught exception: 
java.lang.NoSuchMethodError: No virtual method subscribe(Lrx/functions/Action1;Lrx/functions/Action0;)Lrx/Subscription; in class Lrx/Completable; or its super classes (declaration of 'rx.Completable' appears in /data/app/com.xxx.xxx-1/xxx.apk)
 at com.gfycat.picker.feed.FeedLoadingDelegate.startFeedLoader(FeedLoadingDelegate.java:122)
 at com.gfycat.picker.feed.FeedLoadingDelegate.initialize(FeedLoadingDelegate.java:100)
 at com.gfycat.picker.feed.BaseColumnFeedFragment.onCreate(BaseColumnFeedFragment.java:170)
 at com.gfycat.picker.onecategory.OneCategoryFeedFragment.onCreate(OneCategoryFeedFragment.java:83)
 at android.support.v4.app.Fragment.performCreate(Fragment.java:2236)
 at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1285)
 at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1085)
 at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:976)
 at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:95)
 at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2198)
 at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
 at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
 at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
 at android.os.Handler.handleCallback(Handler.java:739)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:148)
 at android.app.ActivityThread.main(ActivityThread.java:5525)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

Configuration Proguard to -keep all Rx source, and Gfycat, didn't help. Note, that we used Rx all over application (and other libs, included method from stacktrace), but missed source only using Gfycat. Local Project Rx Libs:

    compile 'io.reactivex.rxjava2:rxjava:2.0.8'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
@dgoliy
Copy link
Contributor

dgoliy commented Oct 18, 2017

Hi @GensaGames . I noticed that you are using RxJava2. We are currently using first version. That probably causes issues.
Could you please try adding -keep class rx.** { ; } into your proguard-rules file?
Also, it would be helpful to see your proguard-rules file, so we could try to track this issue.

Thank you!

@dgoliy dgoliy self-assigned this Oct 18, 2017
@dgoliy dgoliy added the bug label Oct 18, 2017
@GensaGames
Copy link
Author

As I mentioned, necessary annotations were added to proguard. We have a lot of setting with rx in proguard files, but also tested with keeping all source throw "-keep class rx.** { ; }", nothing changed. I will update here with proguard.

BTW, that source code from stacktrace, exist and used in many places in application (Rx Observable subsribe using Action on Complete and on Error), but crashing only this library.

@dgoliy
Copy link
Contributor

dgoliy commented Oct 18, 2017

@GensaGames please post your proguard-rules files. Meanwhile, we will try to reproduce it on our side.

@GensaGames
Copy link
Author

GensaGames commented Oct 19, 2017

Proguard file.


# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
.............

-dontoptimize
-dontpreverify
-keepattributes *Annotation*

-keep class io.reactivex.** { *; }
-keep class rx.** { *; }
...............

Could you please include exact version of libraries in your project, to check with local dependencies tree of Gfycat.

@GensaGames
Copy link
Author

Issue was solved by adding resolution strategy to the app gradle. For some reasons Gfycat source using io.reactivex:rxjava:1.1.6 (or somewhere of this version), which over 1.5 years old, and cause issues, since rxjava was changed a lot, from that date (latest version for rxjava, even their first version, 1.3.2).

Added configuration to avoid missing resource (in case your application using different and new versions or rx source, or rxandroid, which is the same in dependencies):

    configurations.all {
        resolutionStrategy {
            force 'io.reactivex:rxandroid:1.2.1', 'io.reactivex:rxjava:1.1.6'
        }
    }

Please, let us know, why you referencing to so old source, and please, add exact version to the Doc. Thanks!

@dekalo-stanislav
Copy link
Contributor

Finally got what was wrong, it is not proguard issue.

In version 1.1.7 rxJava changed Completable::subscribe signature

From:

public final Subscription subscribe(final Action0 onComplete, final Action1<? super Throwable> onError) {

To:

public final Subscription subscribe(final Action1<? super Throwable> onError, final Action0 onComplete) {

So no such method exception is correct.

Gradle default library version resolution strategy is peak latest.
So in your case @GensaGames, I suppose it peaks upper version, that was not compatible.

We will release fix with next sdk version.

Details:
ReactiveX/RxJava#4140
ReactiveX/RxJava@d66d931

@GensaGames
Copy link
Author

As I said, not proguard issue. Please include exact version of the dependecies to the Doc.
Thanks!

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

No branches or pull requests

3 participants