Skip to content

Remove Jetifier - migrate to AndroidX - Gradle build slowdown #609

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

Closed
Woren opened this issue Jan 16, 2025 · 11 comments · Fixed by #610
Closed

Remove Jetifier - migrate to AndroidX - Gradle build slowdown #609

Woren opened this issue Jan 16, 2025 · 11 comments · Fixed by #610

Comments

@Woren
Copy link

Woren commented Jan 16, 2025

Describe the bug

Please migrate Readium from Support Library to AndroidX so android.enableJetifier=true is not any more needed. You can check if this is needed using Build Analyzer tool inside Android Studio. Migration guide is available here. It should be hopefully easy process.

Why it matters?
Enabled Jetifier is significatly impaction build times of the Gradle project based on our experiences with other libraries before/after migration to AndroidX.

Thank you very much.

How to reproduce?

Measure your build time before adding Readium library to your project.
Set android.enableJetifier=true in Gradle project settings.
Measure your build time after.

Readium version

3.0.3

Android API version

23 and higher

Additional context

No response

@mickael-menu
Copy link
Member

We are aware of this issue, but we cannot remove android.enableJetifier because it is required by one of our third-party dependencies (com.github.barteksc:pdfium-android) which currently lacks a suitable open-source replacement.

@mickael-menu mickael-menu closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@mickael-menu
Copy link
Member

Maybe there's a way to Jetify manually the JAR of pdfium-android. This dependency is not maintained anymore, so we could import the JAR directly. Does anybody have experience with that?

@mickael-menu
Copy link
Member

@mickael-menu
Copy link
Member

@Woren Could you test out this PR? Thanks #610

@Woren
Copy link
Author

Woren commented Jan 17, 2025

Firstly thank you for the quick reply!

If I understand this correctly I need to clone mentioned branch (PR) and use it directly? So there are no snapshot builds of this branch?

Also for the future release (if this is merged) we will need to still use cloned repo of main branch or it will work with produced *.aar downloaded from maven? If not build times should be likely better that using Jetifier but there will be some overhead still (hopefully mostly elimined using Gradle cache etc.).

@mickael-menu
Copy link
Member

You need to clone the branch directly.

But if I understand correctly, removing Jetifier will have an impact if you were using the Readium toolkit and compiling it yourself as a local clone (see our README) instead of using Maven Central. In your case, I'm not sure you will see much difference? Gradle caches jetified artifacts pulled from Maven Central so unless you clear your Gradle cache regularly it should not have much impact.

In any case this will work with Maven Central. If not, we will revert back these changes.

@Woren
Copy link
Author

Woren commented Jan 23, 2025

Sorry for little delay. Adding the cloned depedency and syncing project parameters wasn't that straight forward for us.

So in the end it should be working if we didn't mess up something with those dependencies and caches from previous builds. The property "android.enableJetifier" is set to false for our project.

Also in the newly produced jar file of pdfium you can clearly see that "support library" imports are gone and are replaced with "androidx".

In my option this is ready to be merger and thank you for your effort.

@Woren
Copy link
Author

Woren commented Feb 20, 2025

Can I do or check somenthing more or there is any other problem? Please let me know. Thanks.

@mickael-menu
Copy link
Member

I've been working on the Swift toolkit lately so didn't have much time for Kotlin. For this PR there's one thing I'd like to check first, which is whether or not the JAR and SO files are being duplicated in the produced AAR or APK. As they are included in both pdfium-document and pdfium-navigator's Gradle configs.

If you want to help out, you could take a look into that and share the results. That would be very helpful! Thanks.

@Woren
Copy link
Author

Woren commented Feb 25, 2025

Don't worry, I'm glad to help. As far as I can tell, I can't see any SO files duplication. Below is screenshot from APK analyzer in Android Studio. Same SO files can be found in other directories. Similar result is for JAR file (example below). I'm quite sure that in possible case of duplication of classes/packages compiler would signal error. It also happened to me during incorrect setup of the project in the beginning.

Image Image

@mickael-menu
Copy link
Member

Thank you @Woren, this is helpful

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 a pull request may close this issue.

2 participants