Skip to content

Add workaround for androidx toolchain issues: try to load main dispat… #709

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

Merged
merged 3 commits into from
Oct 18, 2018

Conversation

qwwdfsad
Copy link
Collaborator

…cher via Class.forName(..) if ServiceLoader failed to find dispatcher

Fixes #657

…cher via Class.forName(..) if ServiceLoader failed to find dispatcher

Fixes #657
@qwwdfsad qwwdfsad requested a review from elizarov October 16, 2018 09:37
@JakeWharton
Copy link
Contributor

Why this over a @Keep (with actual/expect) or embedding the ProGuard rules inside the jar?

@qwwdfsad
Copy link
Collaborator Author

@JakeWharton

Why this over a @Keep (with actual/expect)

I don't want to have @Keep in core module API (especially if we will make MainDispatcherFactory public at some point), even in compileOnly mode.

or embedding the ProGuard rules inside the jar

To avoid toolchain issues we are not aware of. E.g. there is a lot of proguard rules for RxJava (not RxJava2) in the wild and these rules are not packed into RxJava itself. Class.forName solution "just works", but I have no such confidence about packed proguard rules.
If you are sure both old and new Android toolchains work properly with packed proguard rules and foresee no issues with that, I'd happily add it to the resources (along with -keepclassmembernames class kotlinx.** { volatile <fields>; }.

@JakeWharton
Copy link
Contributor

You can avoid an annotation in the public API with an internal expect annotation in common and an internal actual typealias to the real one in JDK.

Only R8 works with embedded rules, but that shouldn't preclude their use. What's worse is shipping rules solely as documentation that require copy/pasting. Embed the rules in the JAR and have it be the source of truth. Have your documentation link to the rules for people using old toolchains. We should be optimizing for the future so that more and more people will get behavior that Just Works™.

}
```
### R8 and ProGuard
If you are using R8 or ProGuard add the options from [coroutines.pro](core/kotlinx-coroutines-core/resources/META-INF/proguard/coroutines.pro) file to your rules.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style note: let's put an empty line after titles (it reads better in source, since it is actually a separate paragraph).

@qwwdfsad qwwdfsad merged commit aba0edc into release-candidate Oct 18, 2018
@qwwdfsad qwwdfsad deleted the android-workaround branch October 18, 2018 13:05
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

Successfully merging this pull request may close these issues.

3 participants