tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.74k stars 1.21k forks source link

Android: update gradle #13579

Open m1ga opened 1 year ago

m1ga commented 1 year ago

Issue: updateing to gradle > 7.1.0 breaks the SDK build.

Moving the other research parts into this ticket:

the compile errors start as soon as you go to com.android.tools.build:gradle:7.1.0 (current SDK is using 7.0.4 - https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google)

version is set here: https://github.com/search?q=repo%3Atidev%2Ftitanium-sdk+com.android.tools.build%3Agradle%3A7.0.4&type=code (for app and modules)

more infos on gradle updates: https://github.com/tidev/titanium_mobile#upgrade-gradle-and-gradle-plugin

some other issues with gradle updates/infos:

removing

https://github.com/tidev/titanium_mobile/blob/master/android/titanium/build.gradle#L67-L69

and

https://github.com/tidev/titanium_mobile/blob/master/android/titanium/build.gradle#L76-L79

builds but of course breaks the SDK at the end. But it looks like those are the parts that will fail. It doesn't generate the files in runtime/v8/generated so #include "org.appcelerator.kroll.KrollModule.h" will fail during compiling. My guess is that the order of the gradle tasks changed and c++ are not generated before the cmake part

The gradle command ./gradlew :titanium:externalNativeBuildCleanDebug will already trigger the error.

There is a google issue https://issuetracker.google.com/issues/232060576 AGP 7.1 and higher does not build :nativelib module incrementally with "As a workaround we are downgrading AGP." which looks like our issue too. I can remove the .cxx folder and the clean part works but then it breaks at :titanium:buildCMakeRelWithDebInfo[arm64-v8a] with fatal error: 'org.appcelerator.kroll.KrollModule.h' file not found since the files aren't there.

Material lib version

The current version is 1.6.1. If we want to use >=1.7.0 (https://github.com/material-components/material-components-android/releases?expanded=true&page=2&q=1.7.0) we have to use a higher gradle-plugin version

m1ga commented 1 year ago

Interesting part: if you use Studio to run the gradle task :titanium:assembleRelease it will still fail with the same error but continues with other task. After that you can run npm run build (without the clean) and the files are there.

so there is some kind of order error

hansemannn commented 7 months ago

cc @janvennemann

AbdullahFaqeir commented 1 month ago

CC @hansemannn @janvennemann @m1ga

I would love to share this file with you guys after almost 40 hours of working and this is my third day awake.

titanium-sdk-gradle-8.3.1-build.log

I've upgraded Gradle version to the very latest 8.3.1 and I've completely fixed the tasks execution order along side some small fixes to deprecated apis.

m1ga commented 1 month ago

:open_mouth: sounds great! Besides the 3rd day awake part :smile: Looking forward to test it!!!

m1ga commented 1 month ago

To make the real changes a bit easier to check later:

can we merge this one first: https://github.com/tidev/titanium-sdk/pull/13888 ? It is only applying Android Studio recommendations about the style:

    Consider using 'withType(...).configureEach' to avoid unnecessary configuration
    Consider using 'tasks.register' to avoid unnecessary configuration

no code changes in this PR but as this is part of the big gradle change coming up it will make it easier to test in steps.

And since there will be a CMake update too: https://github.com/tidev/titanium-sdk/pull/13966 Don't worry: looks big, but all Java files are just linting because I've raised checkstyle and it's a bit stricter now :smile:

m1ga commented 1 month ago

Huge congrats to @AbdullahFaqeir 🎉

The https://github.com/tidev/titanium-sdk/pull/14014 works! I was able to build kitchensink with it and my app that uses a few modules. I still have to do some more tests but the SDK builds :+1:

Still would like to merge in stages so it's less to review and test. These would be my proposed order:

  1. https://github.com/tidev/titanium-sdk/pull/13888 - styling recommendations
  2. https://github.com/tidev/titanium-sdk/pull/13966 - cmake + checkstyle update
  3. https://github.com/tidev/titanium-sdk/pull/14014 - his gradle stuff (will be a lot less changes when 1 is merged)
  4. if we want: https://github.com/tidev/titanium-sdk/pull/13940 - so we can even use more modules (requires more testing, not required by the Playstore at the moment)