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 #782

Merged
merged 2 commits into from
Jun 24, 2023

Conversation

FelipeSSantos1
Copy link
Contributor

Summary

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.

Test Plan

What's required for testing (prerequisites)?

just build it

What are the steps to test it (after prerequisites)?

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I added a sample use of the API in the example project (example/App.tsx)

@FelipeSSantos1
Copy link
Contributor Author

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

@zoontek zoontek merged commit c037cf1 into zoontek:master Jun 24, 2023
@zoontek
Copy link
Owner

zoontek commented Jun 24, 2023

@felipemillhouse Thanks!

@osamahafez
Copy link

osamahafez commented Jul 3, 2023

@felipemillhouse build fails on previous RN versions

1: Task failed with an exception.

* Where:
Build file '/Users/osamahafez/Software/ThatekWork/mobile/thatek-mobile/node_modules/react-native-permissions/android/build.gradle' line: 62

* What went wrong:
A problem occurred evaluating project ':react-native-permissions'.
> Could not set unknown property 'namespace' for extension 'android' of type com.android.build.gradle.LibraryExtension.

also downgrading to older releases does not fix the issue except 2.0.0 and below

@FelipeSSantos1
Copy link
Contributor Author

I fell it’s not related to the PR @osamahafez

@osamahafez
Copy link

osamahafez commented Jul 3, 2023

@felipemillhouse you can see the issue on line 62 where you submitted the PR
here's the commit: c037cf1

Also I submitted an issue here #787 if you like to investigate further on the matter

@FelipeSSantos1
Copy link
Contributor Author

Is that change released in all versions that you seeing failing? I don’t think so. It’s a new change and it shouldn’t impact previous releases @osamahafez
You can test it checking the node modules folder, deleting the namespace there and trying to build it, likely it’ll fail also

@FelipeSSantos1
Copy link
Contributor Author

If we confirm the root cause is that change, we need to submit another PR like:

// Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
        namespace = "io.sentry.react"
    }

@osamahafez
Copy link

@felipemillhouse I tested it after removing the line namespace = "com.zoontek.rnpermissions"
and build was successful

@FelipeSSantos1
Copy link
Contributor Author

FelipeSSantos1 commented Jul 3, 2023

@felipemillhouse I tested it after removing the line namespace = "com.zoontek.rnpermissions"
and build was successful

Could you make a favor to test with this code?

if (project.android.hasProperty("namespace")) {
        namespace = "com.zoontek.rnpermissions"
    }

I’m far from the computer today and tomorrow, if you could test it would be excellent!
Also few free to send a PR if you are able to, otherwise I’ll send it on Tuesday

renovate bot added a commit to valora-inc/wallet that referenced this pull request Oct 10, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-permissions](https://togithub.com/zoontek/react-native-permissions)
| [`^3.0.3` ->
`^3.9.3`](https://renovatebot.com/diffs/npm/react-native-permissions/3.0.3/3.9.3)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-permissions/3.9.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-permissions/3.9.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-permissions/3.0.3/3.9.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-permissions/3.0.3/3.9.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>zoontek/react-native-permissions
(react-native-permissions)</summary>

###
[`v3.9.3`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.9.3)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.9.2...3.9.3)

- Execute `[CLLocationManager locationServicesEnabled]` in an async way
to prevent UI freezes when checking / requesting location permissions on
iOS
(zoontek/react-native-permissions@82e178f)

###
[`v3.9.2`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.9.2)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.9.1...3.9.2)

- Remove the necessity to declare `NSLocationAlwaysUsageDescription` as
it's deprecated in iOS 17 (fixes
[#&#8203;806](https://togithub.com/zoontek/react-native-permissions/issues/806))
-   Replace missing usage description error logbox with a warning one

###
[`v3.9.1`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.9.1)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.9.0...3.9.1)

- Fix silent fail `onRequestPermissionsResult` for invalid activities
([#&#8203;805](https://togithub.com/zoontek/react-native-permissions/issues/805)
by [@&#8203;webraptor](https://togithub.com/webraptor))

###
[`v3.9.0`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.9.0)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.8.4...3.9.0)

#### Run `setup_permissions` directly in your `Podfile`

This release come with an alternative permission linkage system for iOS:
calling a function, `setup_permissions` inside your `Podfile`.
It offers the same benefits as the `react-native setup-ios-permissions`
command (and actually perform the exact same operation), but it lives in
your `Podfile`, so there's no need to run it each time your delete your
`node_modules` directory.
The only requirement is to run `pod install` when your update your
`Podfile`, which make much more sense 😄
This method also solves issues with monorepos / dependencies hoisting.

To migrate, remove your `reactNativePermissionsIOS` config, and update
your `Podfile`:

```diff

### with react-native >= 0.72
- # Resolve react_native_pods.rb with node to allow for hoisting
- require Pod::Executable.execute_command('node', ['-p',
-   'require.resolve(
-     "react-native/scripts/react_native_pods.rb",
-     {paths: [process.argv[1]]},
-   )', __dir__]).strip

+ def node_require(script)
+   # Resolve script with node to allow for hoisting
+   require Pod::Executable.execute_command('node', ['-p',
+     "require.resolve(
+       '#{script}',
+       {paths: [process.argv[1]]},
+     )", __dir__]).strip
+ end

+ node_require('react-native/scripts/react_native_pods.rb')
+ node_require('react-native-permissions/scripts/setup.rb')
```

```diff

### with react-native < 0.72
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@&#8203;react-native-community/cli-platform-ios/native_modules'
+ require_relative '../node_modules/react-native-permissions/scripts/setup'
```

Then in the same file, call `setup_permissions` with the wanted
permissions:

```ruby

### …

platform :ios, min_ios_version_supported
prepare_react_native_project!

### ⬇️ uncomment wanted permissions (don't forget to remove the last comma)
setup_permissions([

### 'AppTrackingTransparency',
### 'BluetoothPeripheral',

### 'Calendars',
### 'Camera',

### 'Contacts',
### 'FaceID',

### 'LocationAccuracy',
### 'LocationAlways',

### 'LocationWhenInUse',
### 'MediaLibrary',

### 'Microphone',
### 'Motion',

### 'Notifications',
### 'PhotoLibrary',

### 'PhotoLibraryAddOnly',
### 'Reminders',

### 'SpeechRecognition',
### 'StoreKit'
])

### …
```

And run `pod install`. Done! ✨

*📌 The React Native CLI plugin still exists and will not be removed
until next major version.*

***

- `request` now accepts `() => Promise<boolean>` as `rationale`
argument.<br>This way, you can display custom rationale alerts instead
of [the native ones](https://reactnative.dev/docs/alert) (fixes
[zoontek/react-native-permissions#710)

###
[`v3.8.4`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.8.4)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.8.3...3.8.4)

- Only supports iOS 12.4+ with new architecture to prevent compilation
issues
([#&#8203;786](https://togithub.com/zoontek/react-native-permissions/issues/786)
by [@&#8203;hsjoberg](https://togithub.com/hsjoberg))

###
[`v3.8.3`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.8.3)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.8.2...3.8.3)

- Use gradle `namespace` conditionally in order to improve old react
native version compatibility.
*⚠️ Note that this library officially now follows the React Native
[releases support
policy](https://togithub.com/reactwg/react-native-releases#releases-support-policy).
If you have been impacted by this bug, that means you are using an
unsupported react native version and should upgrade to the latest.*

###
[`v3.8.2`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.8.2)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.8.1...3.8.2)

-   Update **Support** mention

###
[`v3.8.1`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.8.1)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.8.0...3.8.1)

- Bump WindowsTargetPlatform by
[@&#8203;TatianaKapos](https://togithub.com/TatianaKapos) for
react-native 0.72 compatibility in
[zoontek/react-native-permissions#771
- Update Android config for react-native 0.73 compatibility by
[@&#8203;felipemillhouse](https://togithub.com/felipemillhouse) in
[zoontek/react-native-permissions#782

###
[`v3.8.0`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.8.0)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.7.3...3.8.0)

- Add new architecture support
([#&#8203;748](https://togithub.com/zoontek/react-native-permissions/issues/748)
by [@&#8203;WoLewicki](https://togithub.com/WoLewicki))

###
[`v3.7.3`](https://togithub.com/zoontek/react-native-permissions/compare/de06cd3a84c9aee5c4f63810c6f707efa35dba67...863d50d24c20139657d0c0c52fd1137c64348158)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.7.2...3.7.3)

###
[`v3.7.2`](https://togithub.com/zoontek/react-native-permissions/compare/5aa5a81f73194b1ebb6b0194d998eec585f98c53...de06cd3a84c9aee5c4f63810c6f707efa35dba67)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.7.1...3.7.2)

###
[`v3.7.1`](https://togithub.com/zoontek/react-native-permissions/compare/db4238213dc1c9601d4e03e864144d8fa31b5411...5aa5a81f73194b1ebb6b0194d998eec585f98c53)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.7.0...3.7.1)

###
[`v3.7.0`](https://togithub.com/zoontek/react-native-permissions/compare/db9ffd0a97e0803fd166aeef7d559e8e33c62984...db4238213dc1c9601d4e03e864144d8fa31b5411)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.6.1...3.7.0)

###
[`v3.6.1`](https://togithub.com/zoontek/react-native-permissions/compare/a5ec1e20dec00f4c606b7c95ede6c459a4e7f605...db9ffd0a97e0803fd166aeef7d559e8e33c62984)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.6.0...3.6.1)

###
[`v3.6.0`](https://togithub.com/zoontek/react-native-permissions/compare/b47e58dc23ec88bdba5befa0ce8c85e8ee7b33f6...a5ec1e20dec00f4c606b7c95ede6c459a4e7f605)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.5.0...3.6.0)

###
[`v3.5.0`](https://togithub.com/zoontek/react-native-permissions/compare/4e08185f16551711f43bdbfb731cf760e5aa0f41...b47e58dc23ec88bdba5befa0ce8c85e8ee7b33f6)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.4.0...3.5.0)

###
[`v3.4.0`](https://togithub.com/zoontek/react-native-permissions/compare/7a9d53eebdc1bc4177aca40846c5b4a2ba214b60...4e08185f16551711f43bdbfb731cf760e5aa0f41)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.3.1...3.4.0)

###
[`v3.3.1`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.3.1)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.3.0...3.3.1)

- Fix test mock
([#&#8203;681](https://togithub.com/zoontek/react-native-permissions/issues/681)
by [@&#8203;rkaartikeyan](https://togithub.com/rkaartikeyan))

###
[`v3.3.0`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.3.0)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.2.0...3.3.0)

- Add `providesAppSettings` support in `NotificationSettings`
([#&#8203;678](https://togithub.com/zoontek/react-native-permissions/issues/678)
by [@&#8203;cwhenderson20](https://togithub.com/cwhenderson20))

###
[`v3.2.0`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.2.0)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.1.0...3.2.0)

- Add Android `ACCESS_MEDIA_LOCATION` permission
([#&#8203;669](https://togithub.com/zoontek/react-native-permissions/issues/669)
by [@&#8203;hectoruiz](https://togithub.com/hectoruiz))

###
[`v3.1.0`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.1.0)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.0.6...3.1.0)

- Add new Android 12 bluetooth permissions
([#&#8203;655](https://togithub.com/zoontek/react-native-permissions/issues/655)
by [@&#8203;jsimonassi](https://togithub.com/jsimonassi))
- Add App Tracking Transparency instructions in the documentation
([#&#8203;657](https://togithub.com/zoontek/react-native-permissions/issues/657)
by [@&#8203;TheWirv](https://togithub.com/TheWirv))
- Fix react-native-windows reference directory
([#&#8203;652](https://togithub.com/zoontek/react-native-permissions/issues/652)
by [@&#8203;JerryMacedoCastro](https://togithub.com/JerryMacedoCastro))

###
[`v3.0.6`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.0.6)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.0.5...3.0.6)

- Make react-native-windows peer dependency optional
([#&#8203;656](https://togithub.com/zoontek/react-native-permissions/issues/656)
by [@&#8203;grit96](https://togithub.com/grit96))

###
[`v3.0.5`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.0.5)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.0.4...3.0.5)

- Export `PERMISSIONS` constants in Jest mock
([#&#8203;628](https://togithub.com/zoontek/react-native-permissions/issues/628)
by [@&#8203;1natsu172](https://togithub.com/1natsu172))

###
[`v3.0.4`](https://togithub.com/zoontek/react-native-permissions/releases/tag/3.0.4)

[Compare
Source](https://togithub.com/zoontek/react-native-permissions/compare/3.0.3...3.0.4)

- Fix Android `requestMultiple` not handling `BLOCKED` state properly
([#&#8203;609](https://togithub.com/zoontek/react-native-permissions/issues/609)
by [@&#8203;Iskander508](https://togithub.com/Iskander508))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <valorabot@valoraapp.com>
Co-authored-by: Jean Regisser <jean.regisser@gmail.com>
Co-authored-by: Satish Ravi <satish.ravi@valoraapp.com>
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

3 participants