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 namespace inside build.gradle file. #1727

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

cortinico
Copy link
Member

Summary:

This commit introduces the support for getting the Android package from the namespace field inside the build.gradle file.

Starting from the recent version of AGP, users should use namespace to setup the package rather than AndroidManifest.xml

Not doing this, is causing this warning on new apps on console:

package="com.androidtemplateproject" found in source AndroidManifest.xml: /tmp/AndroidTemplateProject/android/app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

This commit allows user to setup the namespace inside the build.gradle to suppress this resolve this warning and still being able to build.

Fixes: #1721
Also related to facebook/react-native#35094

Test Plan:

I've wrote Jest tests for this + for also the package parsing which were missing.

This commit introduces the support for getting the Android package
from the `namespace` field inside the build.gradle file.

Starting from the recent version of AGP, users should use namespace
to setup the package rather than AndroidManifest.xml

Not doing this, is causing this warning on new apps on console:
```
package="com.androidtemplateproject" found in source AndroidManifest.xml: /tmp/AndroidTemplateProject/android/app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
```
This commit allows user to setup the namespace inside the build.gradle
to suppress this resolve this warning and still being able to build.
Copy link
Collaborator

@adamTrz adamTrz left a comment

Choose a reason for hiding this comment

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

LGTM.
Thanks for jumping in @cortinico 🎉

@adamTrz adamTrz merged commit 5fbb536 into react-native-community:main Oct 27, 2022
@cortinico
Copy link
Member Author

@adamTrz Can we get a new alpha release with this commit included?

@chenop
Copy link

chenop commented Dec 20, 2022

how to use this fix if react-native 0.70.5 is using @react-native-community/cli 9.2.1?

@TMisiukiewicz
Copy link
Collaborator

hi @chenop this PR was shipped with v10.0.0 of the CLI, so updating to the newest version should help you

@thymikee
Copy link
Member

We could backport this to v9 and issue another release of 0.70.x if that makes sense, I'm just not sure if it does. cc @kelset

@kelset
Copy link
Member

kelset commented Jan 3, 2023

I'm fine either way, but that'd likely mean also a 0.70.x patch and I'm not sure we're planning on making one... we'll figure out later this week I guess.

cc @cortinico any opinions?

@cortinico
Copy link
Member Author

cc @cortinico any opinions?

So this could technically be backported, as it's fully backward compatible. It's probably good to backport, as we'd like libraries to migrate to use namespace sooner or later.

On the other hand, the impact of this is just a warning for now so not super urgent.

thymikee pushed a commit that referenced this pull request Jul 17, 2023
This commit introduces the support for getting the Android package
from the `namespace` field inside the build.gradle file.

Starting from the recent version of AGP, users should use namespace
to setup the package rather than AndroidManifest.xml

Not doing this, is causing this warning on new apps on console:
```
package="com.androidtemplateproject" found in source AndroidManifest.xml: /tmp/AndroidTemplateProject/android/app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
```
This commit allows user to setup the namespace inside the build.gradle
to suppress this resolve this warning and still being able to build.
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 CLI relies on deprecated Package attribute in manifest file
6 participants