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

Add support for RN 0.73 #537

Merged
merged 2 commits into from
Oct 12, 2023
Merged

Conversation

louiszawadzki
Copy link
Contributor

What does this PR do?

This PR brings support to RN 0.73 by adding support for AGP 8.0 (only change impacting us).

Tested:

  • SDK builds and works on RN 0.73.0-rc.1
  • Sourcemaps are uploaded and unminification of JS errors work on RN 0.73.0-rc.1
  • SDK builds and works on RN 0.70

Motivation

Fixes #493

Additional Notes

I think we might also release a 1.8.6 version with this change only once the 0.73 is ready to be released to avoid coupling v2 release (which is still not 100% ready) with RN 0.73 release.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@louiszawadzki louiszawadzki requested a review from a team as a code owner October 9, 2023 09:50
buildFeatures {
buildConfig = true
}
namespace = "com.datadog.reactnative"
Copy link
Member

Choose a reason for hiding this comment

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

by having it here I guess you can now completely delete AndroidManifest file then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try, but I think doing so might break compatibility with RN < 0.71

Copy link
Member

Choose a reason for hiding this comment

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

why? If you are using AGP version which is using this property, then AndroidManifest is not needed if there are only basic things are used there. If AGP version used doesn't have this property, then compilation of build script will fail anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I noticed the following behaviour:

  • if I only remove the package field from the AndroidManifest, the build fails for RN < 0.70 (as already mentioned here)
  • if I remove the whole AndroidManifest file, then the build passes.

So does this mean we did not need this AndroidManifest file from the start?
Are there any functionality we might miss when removing it?

Copy link
Member

Choose a reason for hiding this comment

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

you shouldn't need the manifest file, it is removed in SDK v2 of Android.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have documentation about the support of libraries without a manifest file?
I could not find any docs mentioning that the manifest can be removed: https://developer.android.com/studio/projects/android-library

It seems to work fine with latest versions, but I want to be sure it won't break earlier versions of RN.

Choose a reason for hiding this comment

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

I want to be sure it won't break earlier versions of RN

from what i have seen, rn cli reads the namespace from AndroidManifest.xml in older versions so it will likely fail the build.

Comment on lines +88 to +95
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace = "com.datadog.reactnative"
}
if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
buildFeatures {
buildConfig = true
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not quite sure it will work (but who knows, it is Groovy). If types are statically checked, then this build script won't compile with AGP 6.x even if new properties are wrapped in if. But if things are dynamic (maybe because of Groovy), it will be fine. Does you change work fine if you are running it in the context of AGP 6.x and 7.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested with AGP 4.2.2 (no RN version uses AGP 5.x or 6.x, but can test these as well), and it worked fine.
Also I'm a bit surprised that even if I remove these if conditions everything builds as well 🤷‍♂️

Still, adding these if conditions is what's done by most RN libraries and I might be missing something here. I don't want to spend too much time on this so I think it's ok to go with the safest approach even if it adds a bit of useless code.

@louiszawadzki
Copy link
Contributor Author

Builds for all RN versions are passing in Bitrise, I'm confident to merge this :)

@louiszawadzki louiszawadzki merged commit c5d92df into develop Oct 12, 2023
3 checks passed
@louiszawadzki louiszawadzki deleted the louiszawadzki/RUMM-977/RN0.73-support branch October 12, 2023 16:23
louiszawadzki added a commit that referenced this pull request Oct 30, 2023
@louiszawadzki louiszawadzki mentioned this pull request Oct 30, 2023
4 tasks
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.

RN-0.73 change Android configs for RN 0.73 compatibility
3 participants