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

feat(android): update gradle #13682

Merged
merged 16 commits into from
Feb 8, 2024
Merged

feat(android): update gradle #13682

merged 16 commits into from
Feb 8, 2024

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 17, 2022

Update Gradle tools (not the plugins! Those still fail to build 😞 ) to 7.6

Features:

  • Java 19 support (only had 20 to test here)

Tested:

  • Building SDK
  • Building module
  • Building apps (my app, user app, hyperloop example)
  • Module tests:
    • Tested 12.0.0.RC module in PR app
    • Tested PR module in 12.0.0.RC app
    • Tested 11.1.1.GA modules in PR app

Note:
Changes are by gradle itself using this line. Only this file is changed

@cb1kenobi
Copy link
Contributor

cb1kenobi commented Dec 22, 2022

I tested on Windows with both JDK 17.0.5 and 19 and while both work, the app builds fine, and the app runs fine, I see the following error in the log output:

[INFO]  [GRADLE] Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details
[ERROR] [GRADLE] Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
[ERROR] [GRADLE] Warning: unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
[ERROR] [GRADLE] Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>

Note that these errors do NOT occur with SDK 11.1.0.GA. Is there a way to make Gradle happy?

Side note: Gradle's java.exe process eats up a whopping 1GB of memory. That's not good. What's worse is there doesn't seem to be a way for the Gradle Daemon to shutdown while not in use! So I need to get in the habit of killing all java.exe processes after finishing my coding session. Super lame.

image

@m1ga
Copy link
Contributor Author

m1ga commented Dec 22, 2022

@cb1kenobi I'm using 12.0.0 for a while now and already used to that "error". It doesn't affect the apps.
The solution is to update gradle-plugin #13579 but I wasn't successful in doing that. Also tried to find someone in the gradle community https://discuss.gradle.org/t/build-order-problem-upgrading-build-tools-from-7-0-4-7-2-2/43850 but that wasn't of any help either 😄

Everything from 7.0.x to 7.1.0 or higher breaks the build order as it doesn't have the folders/cpp files ready to continue to build the SDK. But the whole gradle part is not that easy to follow for me as i triggers node stuff and other things. Raising that will fix many warnings and we'll have to do that at some point. For now we can ignore those warnings and I've added flags already that disable Android 33 warnings.

@cb1kenobi
Copy link
Contributor

cb1kenobi commented Dec 22, 2022

@hansemannn What do you make of the Gradle errors in SDK 12? They seem harmless. You think this PR is safe to merge?

I'm a little concerned with not being able to update the gradle-plugin. Maybe that's something I can take a peek at in the next week or so, but I honestly don't know anything about Gradle.

@m1ga
Copy link
Contributor Author

m1ga commented Dec 22, 2022

The error tag is internal, for Gradle its a warning **Warning**: unexpected element (uri:"", local:"extension-level")....

@m1ga
Copy link
Contributor Author

m1ga commented Dec 22, 2022

I'm a little concerned with not being able to update the gradle-plugin. Maybe that's something I can take a peek at in the next week or so, but I honestly don't know anything about Gradle.

That would be awesome if someone else could have a look. There are two places to increase the version:
https://github.com/tidev/titanium_mobile/blob/fa604fac971579225c156a51f749011a416b2c74/android/build.gradle#L16 and https://github.com/tidev/titanium_mobile/blob/80ec88188a6254400c7e9569b722bd9570248a10/android/templates/build/root.build.gradle#L10 (for the module builds later on).

Both have to match otherwise it breaks modules. The module gradle isn't a problem, that works fine. It's just the first one that builds the SDK. 7.3.1 would be the latest stable version but the next iteration 7.1.0 already breaks the builds. Couldn't find anything useful in changelogs. And that there is gradle and "gradle build plugin" doesn't make it easier to search for stuff 😄

@cb1kenobi
Copy link
Contributor

The error tag is internal, for Gradle its a warning **Warning**: unexpected element (uri:"", local:"extension-level")....

Sorry, I misread the output. You are correct sir!

@hansemannn
Copy link
Collaborator

I'm definitely for including it, but maybe not in this GA already to ensure we have more time to properly test. I will also discuss this with @janvennemann and @tpretzel to see if we can get the logs fixed.

@m1ga
Copy link
Contributor Author

m1ga commented Dec 23, 2022

I'm definitely for including it, but maybe not in this GA already to ensure we have more time to properly test.

it's a master PR not for 12.0.0, was supposed to be for the next release 😉

@m1ga
Copy link
Contributor Author

m1ga commented Dec 30, 2022

@hansemannn @cb1kenobi added a fix for the warning color:
tidev/titanium-cli#611

@cb1kenobi
Copy link
Contributor

I accidentally merged tidev/titanium-cli#611 too quickly and reverted it in tidev/titanium-cli#612.

The correct place to fix the Gradle warning is in the createReadableDataHandlerUsing() function: https://github.com/tidev/titanium_mobile/blob/master/android/cli/lib/gradle-wrapper.js#L178-L204

@m1ga
Copy link
Contributor Author

m1ga commented Dec 30, 2022

I'll check those places 👍 Sounds like a better way to fix it

@hansemannn
Copy link
Collaborator

hansemannn commented Jan 31, 2023

Adding two more logs here to have all at one place:

[INFO]  Building app
[INFO]  [GRADLE] This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>
[INFO]  [GRADLE] Errors limit exceeded. To receive all errors set com.sun.xml.bind logger to FINEST level.
[INFO]  [GRADLE] unexpected element (uri:"", local:"base-extension"). Expected elements are <{}vendor>,<{}codename>,<{}abi>,<{}api-level>,<{}tag>

and

[INFO]  [GRADLE] Relying on FileTrees for ignoring empty directories when using @SkipWhenEmpty has been deprecated. This is scheduled to be removed in Gradle 8.0. Annotate the property inputFiles with @IgnoreEmptyDirectories or remove @SkipWhenEmpty. Consult the upgrading guide for further information: https://docs.gradle.org/7.4.2/userguide/upgrading_version_7.html#empty_directories_file_tree

@hansemannn
Copy link
Collaborator

@m1ga Can you maybe give a summary on the challenges / todos of this change? We plan to tackle this in Q4 and it would help a lot to know which open issues there are right now. IIRC, we want to prevent breaking modules. But if it can be solved by doing so, it would be a bearable solution, looking at how many times this happened (for good reasons) over the last SDKs.

@m1ga
Copy link
Contributor Author

m1ga commented Sep 27, 2023

this PR was fine. We had had issues testing it on Windows.

The problematic one is #13579 when updating com.android.tools.build:gradle from 7.0.4 to any higher version (7.1.0 is the next one). That will break building the SDK as it won't create the C files before trying to use them.

@m1ga
Copy link
Contributor Author

m1ga commented Feb 8, 2024

Tested this PR again:

Fedora Linux, Android 14/Pixel 7

Java 17 (current max version we support)

  • build Android SDK ✔️
  • Ti Android SDK test suite ✔️
  • kitchensink app ✔️
  • hyperloop-examples ✔️
  • two different apps with existing modules ✔️
  • building android modules ✔️
  • build apps with rebuild modules ✔️
  • build apps with 12.2.1.GA + modules that were build with 12.3.0 ✔️

Java 20

  • build Android SDK ✔️
  • Ti Android SDK test suite ✔️
  • kitchensink app ✔️
  • hyperloop-examples ✔️
  • two different apps with existing modules ✔️
  • building android modules ✔️
  • build apps with rebuild modules ✔️
  • build apps with 12.2.1.GA + modules that were build with 12.3.0 ✔️

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

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

Tested on Windows, Java 20, built basic 2-tab app, and everything works!

@cb1kenobi cb1kenobi merged commit e41650c into master Feb 8, 2024
5 checks passed
@m1ga
Copy link
Contributor Author

m1ga commented Feb 8, 2024

I'm soooo confused. After working with 12.3.0 (with this PR) and Java 20 the whole day I've tried to build a different PR with Android Studio a few minutes ago and now I'm getting:

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 64

the whole time. I even switched Java back to 17 and delete the whole ~./gradle folder, killed all java processes and gradle. Still complaining about major version 64 (which is Java 20) 🤷 What did it break all of the sudden?!

@cb1kenobi
Copy link
Contributor

@m1ga I didn't see a problem. You're on Linux, right?

@m1ga
Copy link
Contributor Author

m1ga commented Feb 8, 2024

a restart fixed the error! Which is not really helping me to find the source of it. I'll keep investigating and check if the issue appears again. It started once I've opened Android Studio trying to build an old PR. Perhaps that mixed up gradle somehow.

@m1ga m1ga deleted the gradleUpdate branch March 21, 2024 17:53
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