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

R8 has built-in support for ServiceLoader, Proguard rules need update #3111

Closed
vvb2060 opened this issue Dec 27, 2021 · 1 comment
Closed

Comments

@vvb2060
Copy link

vvb2060 commented Dec 27, 2021

https://r8.googlesource.com/r8/+/c93796dcf5f2f74d7c3817926cbfbf3122096a74

    private final ProguardPathFilter.Builder adaptResourceFilenames =
        ProguardPathFilter.builder()
            .addPattern(ProguardPathList.builder().addFileName("META-INF/services/*").build());
    private final ProguardPathFilter.Builder adaptResourceFileContents =
        ProguardPathFilter.builder()
            .addPattern(ProguardPathList.builder().addFileName("META-INF/services/*").build());

R8 use -adaptresourcefilenames and -adaptresourcefilecontents to handle META-INF/services/*, which I think is better than -keep or -keepnames: https://www.guardsquare.com/manual/configuration/examples#resourcefiles

The following rules can be removed:

-keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;}
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}

@Keep
internal class AndroidExceptionPreHandler :
AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler

@agrieve
Copy link
Contributor

agrieve commented Apr 8, 2022

I was just looking at this as well, and it turns out that:
a) There is still a -keep rule in kotlinx-coroutines-android that should be removed, and
b) R8 natively supports META-INF/services / ServiceLoader.load since 1.5, so there's also no need for -adaptresourcefilecontents / -adaptresourcefilenames

pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
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

2 participants