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

RN-0.73 change Android configs for RN 0.73 compatibility #600

Merged
merged 3 commits into from
Jul 28, 2023

Conversation

FelipeSSantos1
Copy link
Contributor

Starting from React Native v0.73 , all libraries will need to be updated with these two one-liners due to Android Gradle Plugin upgrade
react-native-community/discussions-and-proposals#671


React Native 0.73 will depend on Android Gradle Plugin (AGP) 8.x. This will require all the libraries to specify a namespace in their build.gradle file.

Details
I'd like to share some of the upcoming changes that will happen in 0.73, which is still a bit far, but we'd rather start earlier rather than later.

React Native 0.73 will depend on Android Gradle Plugin (AGP) 8.x, which brings a lot of improvements for Android apps but also a series of notable changes.

Most importantly:

App/Library Developers will now have to install and use Java 17
Library Developers will have to specify a namespace in their build.gradle file.
Specifically, the last change is a breaking change and will make libraries that are not specifying a namespace incompatible with React Native 0.73 (your project won't build).

Support for namespace was added in AGP 7.3.x, which ships with React Native 0.71. Libraries that published a new version with a namespace declared for 0.71 or 0.72 don't need further update. So we invite library authors to do those changes as soon as possible so by the time 0.73 is out, most of the apps are adapted.

What you need to change
Library authors will have to update their android/build.gradle file as follows:

android {
+   namespace = "com.iterable.reactnative"
    ...
}

and remove the package definition from their AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.iterable.reactnative">
+          >
...
</manifest>

Further reading
Official Google documentation on namespaces is here.

@FelipeSSantos1
Copy link
Contributor Author

I added back the namespace to AndroidManifest to keep previous RN compatibility
react-native-community/discussions-and-proposals#671 (comment)

@keeslinp
Copy link

I'm going through the process of patching all my dependencies and noticed that some of them have a conditional check to keep gradle <=7 working. Maybe that's something you need here to?
https://github.com/kirillzyusko/react-native-keyboard-controller/blob/25980c9dc5f8644046ad46938f23db0d163350f5/android/build.gradle#L43

  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
    namespace "com.reactnativekeyboardcontroller"
  }

android/build.gradle Outdated Show resolved Hide resolved
@FelipeSSantos1
Copy link
Contributor Author

FelipeSSantos1 commented Jul 10, 2023

I'm going through the process of patching all my dependencies and noticed that some of them have a conditional check to keep gradle <=7 working. Maybe that's something you need here to? https://github.com/kirillzyusko/react-native-keyboard-controller/blob/25980c9dc5f8644046ad46938f23db0d163350f5/android/build.gradle#L43

  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
  if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
    namespace "com.reactnativekeyboardcontroller"
  }

@keeslinp
I just update it following Sentry team implementation https://github.com/getsentry/sentry-react-native/blob/main/android/build.gradle#L17C5-L18C52

@oblador oblador merged commit 49756db into oblador:master Jul 28, 2023
3 checks passed
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.

None yet

4 participants