Skip to content

Gradle build fails with Android Studio Flamingo update #5208

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
sivasubramaniamv opened this issue Apr 15, 2023 · 9 comments · Fixed by #5220
Closed

Gradle build fails with Android Studio Flamingo update #5208

sivasubramaniamv opened this issue Apr 15, 2023 · 9 comments · Fixed by #5220

Comments

@sivasubramaniamv
Copy link
Contributor

sivasubramaniamv commented Apr 15, 2023

Summary

Gradle build fails after updating to the latest Android Studio stable release (Flamingo)

Why does it fail?

Android studio Flamingo comes bundled with JDK 17. The minimum Gradle version to support JDK 17 is Gradle 7.3. But the project currently uses Gradle 6.9.

image

After upgrading Gradle from 6.9 to 7.3, the build still fails with the following error.

image

This is caused due to error in the build.gradle file of the data-client ie: wikimedia-android-data-client library, rather than the build.gradle of the commons app.

Steps to reproduce

  1. Upgrade Android Studio to Flamingo
  2. Open apps-android-commons project
  3. The build fails with the said error

Expected behaviour

The build error is expected as the Gradle version is incompatible with the JDK version.

Actual behaviour

NA

Device name

Realme 3 pro

Android version

Android 11

Commons app version

4.0.3-debug

Device logs

No response

Screen-shots

No response

Would you like to work on the issue?

Yes

@nicolas-raoul
Copy link
Member

Thanks! The best thing to do would be to send a pull request (or equivalent) to the library's source repository, and use that fork until the pull request gets merged.

@sivasubramaniamv
Copy link
Contributor Author

sivasubramaniamv commented Apr 15, 2023

image

@nicolas-raoul The library is not included as a dependency in the commons app project gradle files, rather the entire codebase of the library has been copied into the data-client folder & the folder is included as a project in the commons app build.gradle file.

implementation project(':wikimedia-data-client')

image

And the path for the project is specified in settings.gradle file of commons app project

project(':wikimedia-data-client').projectDir = new File('data-client')

image

So it'd be of no use even if a pull request to the library repository fixes the said error unless the library is included as a dependency in build.gradle file of the commons app project, rather than having the entire codebase copied into it.

The library repository seems to have got some updates compared to the code present in the commons app project but has not received any updates after November 2019.

Actually, this error should have been reported in the wikimedia-android-data-client GitHub repository as it is concerned with publishing of the library and has nothing to do with the commons app itself.

The best thing we could do to fix this quickly is to fix it ourselves within this project. I will try, but I suggest this issue be assigned to someone with good knowledge of gradle & publishing libraries.

I'm leaving links to resources I found that'd be helpful in solving this issue:

  1. Stack Overflow Discussion
  2. Medium Article

If there's no compelling reason to have the entire library within the commons app project, I highly suggest using the library as a dependency rather than having the entire codebase inside this project to avoid such errors in the future.

@sivasubramaniamv
Copy link
Contributor Author

sivasubramaniamv commented Apr 17, 2023

After contacting the author of the library, it is clear that it does not have active development. The author has just archived the repository. He told that the library is outdated and suggested commons app gradually move to its own solution with modern tools and practices. I'm working on a temporary solution to just make it work for now.

@nicolas-raoul
Copy link
Member

Thanks Siva! Even though the long-term solution is probably migration (per #5165), a short-time fix seems needed too, if I understand correctly.

@sivasubramaniamv
Copy link
Contributor Author

sivasubramaniamv commented Apr 17, 2023

You're right Nicolas. People are going to update their Android Studio as usual & the build will fail, affecting further development. I'm working on a temporary solution now.

Update

I was fixing various build errors after upgrading Gradle to 7.5 and AGP to 7.4.2 until I faced an error for which @madhurgupta10 has raised an issue in the Google issue tracker.

image

This comment on that issue suggests that the problem is likely to be fixed in AGP version 8.0 which requires a minimum Gradle version of 8.0.

But upgrading to Gradle 8.0 and AGP 8.0 is likely to take some time as there is quite some work to do in the build configuration.

image

I'm trying to get this fixed ASAP.

@sivasubramaniamv
Copy link
Contributor Author

sivasubramaniamv commented Apr 18, 2023

I've successfully upgraded AGP and Gradle to the latest version (AGP 8.0.0, Gradle 8.0) but the error still persists.

image

This comment in a similar issue suggests a potential fix.

I've asked a question in stack overflow hoping for an answer.

@sivasubramaniamv
Copy link
Contributor Author

@nicolas-raoul Can you review my pull request?

@shankarpriyank
Copy link
Contributor

Is this fixed?
Are there any temporary workarounds?

@sivasubramaniamv
Copy link
Contributor Author

Is this fixed?
Are there any temporary workarounds?

Merging this pull request should solve the issue.

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