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

Never call done when proguard enforcing #177

Open
ghost opened this issue Sep 2, 2020 · 3 comments
Open

Never call done when proguard enforcing #177

ghost opened this issue Sep 2, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 2, 2020

when(...).done(my function)
May lose effect when I turn on proguard.
It seems like this plugin just execute code block which into brackets follow closely "when" and code block keep up with done will never be executed. ( Even if code in when block is empty ).
I can not see any crash report or exception in logcat, and it seems like that thread exit after code block in brackets follow closely "when" execute finish.
Turn off minify, this problem will be solved.
Is there any keep rules about this project?
This problem never occur in previous version( 1.x.x ).

@saturnism
Copy link
Member

hi @lianglixin! I have not used proguard to test this, but we didn't have any extra rules.

will you be able to share some code to reproduce this?

@ghost
Copy link
Author

ghost commented Sep 3, 2020

hi @lianglixin! I have not used proguard to test this, but we didn't have any extra rules.

will you be able to share some code to reproduce this?

Dear developer, I copy my code below

// I put this line in my application gradle file, I found that org.jdeferred.v2 library with the same problem.
implementation 'org.jdeferred:jdeferred-android-aar:1.2.6'

// Then I put those code in MainActivity.java -> onCreate method

new AndroidDeferredManager()
.when(()->
{
System.out.println("I am Liang Lixin");
}).done((resultObj)->
{
runOnUiThread(()->
{
Toast.makeText(MainActivity.this,"test",Toast.LENGTH_SHORT).show();
});
});

I will get a toast when minifyEnabled is false, but done may never execute when I set it to true.
And I use code below, this problem will never recur.

new Thread()
{
@Override
public void run()
{
super.run();
System.out.println("I'm Liang Lixin");
runOnUiThread(()->
{
Toast.makeText(MainActivity.this,"test",Toast.LENGTH_SHORT).show();
});
}
}.start();

I think there is a keep rule like -keep class org.jdeferred.** { *; } can solve.

@saturnism
Copy link
Member

Thanks for clarifying. I'm not sure what the process of minify is. I'm wondering if you are able to use the jar directly, and let android compiler to interpret the bytecode directly? https://mvnrepository.com/artifact/org.jdeferred/jdeferred-android

I'm not sure if it'll make a difference but curious!

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

1 participant