Skip to content

[Android] Upcoming changes for libraries in React Native 0.73 #671

Closed
@cortinico

Description

@cortinico

TL;DR

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. We added a compatibility layer for libraries that haven't specified a namespace, but please consider updating your libraries nonetheless.

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:

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.example.mylibrary"
    ...
}

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.example.mylibrary">
+          >
...
</manifest>

Compatibility Layer

We added a compatiblity layer inside React Native 0.73, that will make sure that namespace is configured for each libraries, even if you don't update the library. This will make sure 0.73 works also with older libraries that are not receiving may updates.
Still consider updating your library to keep up to date with the Android best practices.

Further reading

Official Google documentation on namespaces is here.


Please update your libraries whenever possible, adding the namespace declaration and let us know if this is creating any issues for you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions