react-native-ble-manager 8.8.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +93 -44
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  11. package/android/.gradle/7.4/gc.properties +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/file-system.probe +0 -0
  16. package/android/.gradle/vcs-1/gc.properties +0 -0
  17. package/android/.idea/.name +1 -0
  18. package/android/.idea/compiler.xml +6 -0
  19. package/android/.idea/gradle.xml +18 -0
  20. package/android/.idea/jarRepositories.xml +40 -0
  21. package/android/.idea/misc.xml +10 -0
  22. package/android/.idea/vcs.xml +6 -0
  23. package/android/build.gradle +17 -17
  24. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  25. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  26. package/android/gradle.properties +3 -1
  27. package/android/gradlew +234 -0
  28. package/android/gradlew.bat +89 -0
  29. package/android/local.properties +8 -0
  30. package/android/src/main/java/it/innove/BleManager.java +18 -17
  31. package/android/src/main/java/it/innove/LegacyScanManager.java +33 -28
  32. package/android/src/main/java/it/innove/LollipopPeripheral.java +66 -65
  33. package/android/src/main/java/it/innove/LollipopScanManager.java +52 -25
  34. package/android/src/main/java/it/innove/Peripheral.java +889 -837
  35. package/android/src/main/java/it/innove/ScanManager.java +24 -23
  36. package/dist/cjs/index.d.ts +147 -0
  37. package/dist/cjs/index.js +487 -0
  38. package/dist/cjs/index.js.map +1 -0
  39. package/dist/cjs/types.d.ts +311 -0
  40. package/dist/cjs/types.js +110 -0
  41. package/dist/cjs/types.js.map +1 -0
  42. package/dist/esm/index.d.ts +147 -0
  43. package/dist/esm/index.js +471 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/types.d.ts +311 -0
  46. package/dist/esm/types.js +107 -0
  47. package/dist/esm/types.js.map +1 -0
  48. package/ios/BleManager.m +87 -110
  49. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  50. package/package.json +31 -4
  51. package/src/index.ts +569 -0
  52. package/src/types.ts +336 -0
  53. package/.github/FUNDING.yml +0 -3
  54. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  55. package/BleManager.js +0 -427
  56. package/index.d.ts +0 -294
package/README.md CHANGED
@@ -4,7 +4,13 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/react-native-ble-manager.svg?style=flat)](https://www.npmjs.com/package/react-native-ble-manager)
5
5
  [![GitHub issues](https://img.shields.io/github/issues/innoveit/react-native-ble-manager.svg?style=flat)](https://github.com/innoveit/react-native-ble-manager/issues)
6
6
 
7
- This is a porting of https://github.com/don/cordova-plugin-ble-central project to React Native.
7
+ A React Native Bluetooth Low Energy library.
8
+
9
+ Originally inspired by https://github.com/don/cordova-plugin-ble-central.
10
+
11
+ ## Introduction
12
+
13
+ The library is a simple connection with the OS APIs, the BLE stack should be standard but often has different behaviors based on the device used, the operating system and the BLE chip it connects to. Before opening an issue verify that the problem is really the library.
8
14
 
9
15
  ## Requirements
10
16
 
@@ -35,28 +41,41 @@ The library support the react native autolink feature.
35
41
  xmlns:tools="http://schemas.android.com/tools"
36
42
  package="YOUR_PACKAGE_NAME">
37
43
 
38
- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
39
- <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
44
+ <!--
45
+ HACK: this permission should not be needed on android 12+ devices anymore,
46
+ but in fact some manufacturers still need it for BLE to properly work :
47
+ https://stackoverflow.com/a/72370969
48
+ -->
49
+ <uses-permission android:name="android.permission.BLUETOOTH" tools:remove="android:maxSdkVersion" />
50
+ <!--
51
+ should normally only be needed on android < 12 if you want to:
52
+ - activate bluetooth programmatically
53
+ - discover local BLE devices
54
+ see: https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#discover-local-devices.
55
+ Same as above, may still be wrongly needed by some manufacturers on android 12+.
56
+ -->
57
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" tools:remove="android:maxSdkVersion" />
40
58
 
41
59
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28"/>
42
- <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" tools:targetApi="Q"/>
60
+ <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
43
61
 
44
62
  <!-- Only when targeting Android 12 or higher -->
45
- <!-- Please make sure you read the following documentation to have a
46
- better understanding of the new permissions.
47
- https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location
48
- -->
49
-
50
- <!-- If your app doesn't use Bluetooth scan results to derive physical location information,
51
- you can strongly assert that your app
52
- doesn't derive physical location. -->
53
- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"
54
- android:usesPermissionFlags="neverForLocation"
55
- tools:targetApi="s" />
56
-
57
- <!-- Needed only if your app looks for Bluetooth devices. -->
58
- <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
59
- <!-- Needed only if your app makes the device discoverable to Bluetooth devices. -->
63
+ <!--
64
+ Please make sure you read the following documentation
65
+ to have a better understanding of the new permissions.
66
+ https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location
67
+ -->
68
+
69
+ <!-- Needed if your app search for Bluetooth devices. -->
70
+ <!--
71
+ If your app doesn't use Bluetooth scan results to derive physical location information,
72
+ you can strongly assert that your app doesn't derive physical location.
73
+ -->
74
+ <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
75
+ android:usesPermissionFlags="neverForLocation" />
76
+ <!-- Needed if you want to interact with a BLE device. -->
77
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
78
+ <!-- Needed if your app makes the current device discoverable to other Bluetooth devices. -->
60
79
  <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
61
80
  ...
62
81
  ```
@@ -75,7 +94,7 @@ In iOS >= 13 you need to add the `NSBluetoothAlwaysUsageDescription` string key.
75
94
  - Android API >= 29 require the ACCESS_FINE_LOCATION permission to scan for peripherals.
76
95
  React-Native 0.63.X started targeting Android API 29.
77
96
  - Before write, read or start notification you need to call `retrieveServices` method
78
- - Because location and bluetooth permissions are runtime permissions, you **must** request these permissions at runtime along with declaring them in your manifest.
97
+ - Because location and bluetooth permissions are runtime permissions, you **must** request these permissions at runtime along with declaring them in your manifest.
79
98
 
80
99
  ## Example
81
100
 
@@ -86,11 +105,14 @@ The easiest way to test is simple make your AppRegistry point to our example com
86
105
  import React, { Component } from "react";
87
106
  import { AppRegistry } from "react-native";
88
107
  import App from "react-native-ble-manager/example/App"; //<-- simply point to the example js!
89
-
108
+ /*
109
+ Note: The react-native-ble-manager/example directory is only included when cloning the repo, the above import will not work
110
+ if trying to import react-native-ble-manager/example from node_modules
111
+ */
90
112
  AppRegistry.registerComponent("MyAwesomeApp", () => App);
91
113
  ```
92
114
 
93
- Or, you can still look into the whole [example](https://github.com/innoveit/react-native-ble-manager/tree/master/example) folder for a standalone project.
115
+ Or, [use the example directly](example)
94
116
 
95
117
  ## Methods
96
118
 
@@ -131,13 +153,14 @@ Returns a `Promise` object.
131
153
  - `seconds` - `Integer` - the amount of seconds to scan.
132
154
  - `allowDuplicates` - `Boolean` - [iOS only] allow duplicates in device scanning
133
155
  - `scanningOptions` - `JSON` - [Android only] after Android 5.0, user can control specific ble scan behaviors:
134
- - `numberOfMatches` - `Number` - [Android only] corresponding to [`setNumOfMatches`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setNumOfMatches(int)>). Defaults to `ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT`.
156
+ - `numberOfMatches` - `Number` - [Android only] corresponding to [`setNumOfMatches`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setNumOfMatches(int)>). Defaults to `ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT`. /!\ anything other than default may only work when a `ScanFilter` is active /!\
135
157
  - `matchMode` - `Number` - [Android only] corresponding to [`setMatchMode`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setMatchMode(int)>). Defaults to `ScanSettings.MATCH_MODE_AGGRESSIVE`.
136
- - `callbackType` - `Number` - [Android only] corresponding to [`setCallbackType`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setCallbackType(int)>). Defaults `ScanSettings.CALLBACK_TYPE_ALL_MATCHES`.
158
+ - `callbackType` - `Number` - [Android only] corresponding to [`setCallbackType`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setCallbackType(int)>). Defaults `ScanSettings.CALLBACK_TYPE_ALL_MATCHES`. /!\ anything other than default may only work when a `ScanFilter` is active /!\
137
159
  - `scanMode` - `Number` - [Android only] corresponding to [`setScanMode`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setScanMode(int)>). Defaults to `ScanSettings.SCAN_MODE_LOW_POWER`.
138
160
  - `reportDelay` - `Number` - [Android only] corresponding to [`setReportDelay`](<https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder.html#setReportDelay(long)>). Defaults to `0ms`.
139
161
  - `phy` - `Number` - [Android only] corresponding to [`setPhy`](https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setPhy(int))
140
162
  - `legacy` - `Boolean` - [Android only] corresponding to [`setLegacy`](https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean))
163
+ - `exactAdvertisingName` - `string` - [Android only] corresponds to the `ScanFilter` [deviceName](https://developer.android.com/reference/android/bluetooth/le/ScanFilter.Builder#setDeviceName(java.lang.String))
141
164
 
142
165
  **Examples**
143
166
 
@@ -238,12 +261,13 @@ BleManager.enableBluetooth()
238
261
 
239
262
  ### checkState()
240
263
 
241
- Force the module to check the state of BLE and trigger a BleManagerDidUpdateState event.
264
+ Force the module to check the state of the native BLE manager and trigger a BleManagerDidUpdateState event.
265
+ Resolves to a promise containing the current BleState.
242
266
 
243
267
  **Examples**
244
268
 
245
269
  ```js
246
- BleManager.checkState();
270
+ BleManager.checkState().then(state => console.log(`current BLE state = '${state}'.`));
247
271
  ```
248
272
 
249
273
  ### startNotification(peripheralId, serviceUUID, characteristicUUID)
@@ -320,7 +344,8 @@ Returns a `Promise` object.
320
344
  ### read(peripheralId, serviceUUID, characteristicUUID)
321
345
 
322
346
  Read the current value of the specified characteristic, you need to call `retrieveServices` method before.
323
- Returns a `Promise` object.
347
+ Returns a `Promise` object that will resolves to an array of plain integers (`number[]`) representing a `ByteArray` structure.
348
+ That array can then be converted to a JS `ArrayBuffer` for example using `Buffer.from()` [thanks to this buffer module](https://github.com/feross/buffer).
324
349
 
325
350
  **Arguments**
326
351
 
@@ -340,7 +365,9 @@ BleManager.read(
340
365
  // Success code
341
366
  console.log("Read: " + readData);
342
367
 
343
- const buffer = Buffer.Buffer.from(readData); //https://github.com/feross/buffer#convert-arraybuffer-to-buffer
368
+ // https://github.com/feross/buffer
369
+ // https://nodejs.org/api/buffer.html#static-method-bufferfromarray
370
+ const buffer = Buffer.from(readData);
344
371
  const sensorData = buffer.readUInt8(1, true);
345
372
  })
346
373
  .catch((error) => {
@@ -359,25 +386,31 @@ Returns a `Promise` object.
359
386
  - `peripheralId` - `String` - the id/mac address of the peripheral.
360
387
  - `serviceUUID` - `String` - the UUID of the service.
361
388
  - `characteristicUUID` - `String` - the UUID of the characteristic.
362
- - `data` - `Byte array` - the data to write.
389
+ - `data` - `number[]` - the data to write as a plain integer array representing a `ByteArray` structure.
363
390
  - `maxByteSize` - `Integer` - specify the max byte size before splitting message, defaults to 20 bytes if not specified
364
391
 
365
392
  **Data preparation**
366
393
 
367
- If your data is not in byte array format you should convert it first. For strings you can use `convert-string` or other npm package in order to achieve that.
368
- Install the package first:
369
-
370
- ```shell
371
- npm install convert-string
372
- ```
394
+ To convert your data to a `number[]`, you should probably be manipulating a `Buffer` or anything representing a JS `ArrayBuffer`.
395
+ This will make sure you are converting from valid byte representations of your data first and not with [an integer outside the expected range](https://techtutorialsx.com/2019/10/27/node-js-converting-array-to-buffer/).
373
396
 
374
- Then use it in your application:
397
+ You can create a buffer from files, numbers or strings easily (see examples bellow).
375
398
 
376
399
  ```js
377
- // Import/require in the beginning of the file
378
- import { stringToBytes } from "convert-string";
379
- // Convert data to byte array before write/writeWithoutResponse
380
- const data = stringToBytes(yourStringData);
400
+ // https://github.com/feross/buffer
401
+ import { Buffer } from 'buffer';
402
+
403
+ * // Creates a Buffer containing the bytes [0x01, 0x02, 0x03].
404
+ * const buffer = Buffer.from([1, 2, 3]);
405
+ *
406
+ * // Creates a Buffer containing the bytes [0x01, 0x01, 0x01, 0x01] – the entries
407
+ * // are all truncated using `(value & 255)` to fit into the range 0–255.
408
+ * const buffer = Buffer.from([257, 257.5, -255, '1']);
409
+ *
410
+ * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
411
+ * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
412
+ * // [116, 195, 169, 115, 116] (in decimal notation)
413
+ * const buffer = Buffer.from('tést');
381
414
  ```
382
415
 
383
416
  Feel free to use other packages or google how to convert into byte array if your data has other format.
@@ -389,7 +422,9 @@ BleManager.write(
389
422
  "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
390
423
  "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
391
424
  "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
392
- data
425
+ // encode & extract raw `number[]`.
426
+ // Each number should be in the 0-255 range as it is converted from a valid byte.
427
+ buffer.toJSON().data
393
428
  )
394
429
  .then(() => {
395
430
  // Success code
@@ -411,13 +446,13 @@ Returns a `Promise` object.
411
446
  - `peripheralId` - `String` - the id/mac address of the peripheral.
412
447
  - `serviceUUID` - `String` - the UUID of the service.
413
448
  - `characteristicUUID` - `String` - the UUID of the characteristic.
414
- - `data` - `Byte array` - the data to write.
449
+ - `data` - `number[]` - the data to write as a plain integer array representing a `ByteArray` structure. (see `write()`).
415
450
  - `maxByteSize` - `Integer` - (Optional) specify the max byte size
416
451
  - `queueSleepTime` - `Integer` - (Optional) specify the wait time before each write if the data is greater than maxByteSize
417
452
 
418
453
  **Data preparation**
419
454
 
420
- If your data is not in byte array format check info for the write function above.
455
+ If your data is not in `number[]` format check info fom the `write()` function example above.
421
456
 
422
457
  **Example**
423
458
 
@@ -576,7 +611,7 @@ BleManager.getConnectedPeripherals([]).then((peripheralsArray) => {
576
611
  ### createBond(peripheralId,peripheralPin) [Android only]
577
612
 
578
613
  Start the bonding (pairing) process with the remote device. If you pass peripheralPin(optional), bonding will be auto(without manual entering pin)
579
- Returns a `Promise` object. The promise is resolved when either `new bond successfully created` or `bond already existed`, otherwise it will be rejected.
614
+ Returns a `Promise` object that will resolves if the bond is successfully created, otherwise it will be rejected with the appropriate error message.
580
615
 
581
616
  **Examples**
582
617
 
@@ -838,3 +873,17 @@ The peripheral received a request to start or stop providing notifications for a
838
873
  - `isNotifying` - `Boolean` - Is the characteristic notifying or not
839
874
  - `domain` - `String` - [iOS only] error domain
840
875
  - `code` - `Number` - [iOS only] error code
876
+
877
+ ## Library development
878
+
879
+ - the library is written in typescript and needs to be built before being used for publication or local development, using the provided npm scripts in `package.json`.
880
+ - the local `example` project is configured to work with the locally built version of the library. To be able to run it, you need to build at least once the library so that its outputs listed as entrypoint in `package.json` (in the `dist` folder) are properly generated for consumption by the example project:
881
+
882
+ from the root folder:
883
+
884
+ ```shell
885
+ npm install
886
+ npm run build
887
+ ```
888
+
889
+ > if you are modifying the typescript files of the library (in `src/`) on the fly, you can run `npm run watch` instead. If you are modifying files from the native counterparts, you'll need to rebuild the whole app for your target environnement (`npm run android/ios`).
File without changes
@@ -0,0 +1,2 @@
1
+ #Wed Dec 14 11:37:11 CET 2022
2
+ gradle.version=7.4
File without changes
@@ -0,0 +1 @@
1
+ react-native-ble-manager
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <bytecodeTargetLevel target="1.8" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleMigrationSettings" migrationVersion="1" />
4
+ <component name="GradleSettings">
5
+ <option name="linkedExternalProjectsSettings">
6
+ <GradleProjectSettings>
7
+ <option name="testRunner" value="GRADLE" />
8
+ <option name="distributionType" value="DEFAULT_WRAPPED" />
9
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
10
+ <option name="modules">
11
+ <set>
12
+ <option value="$PROJECT_DIR$" />
13
+ </set>
14
+ </option>
15
+ </GradleProjectSettings>
16
+ </option>
17
+ </component>
18
+ </project>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RemoteRepositoriesConfiguration">
4
+ <remote-repository>
5
+ <option name="id" value="central" />
6
+ <option name="name" value="Maven Central repository" />
7
+ <option name="url" value="https://repo1.maven.org/maven2" />
8
+ </remote-repository>
9
+ <remote-repository>
10
+ <option name="id" value="jboss.community" />
11
+ <option name="name" value="JBoss Community repository" />
12
+ <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
13
+ </remote-repository>
14
+ <remote-repository>
15
+ <option name="id" value="maven" />
16
+ <option name="name" value="maven" />
17
+ <option name="url" value="file:$PROJECT_DIR$/../node_modules/react-native/android" />
18
+ </remote-repository>
19
+ <remote-repository>
20
+ <option name="id" value="MavenRepo" />
21
+ <option name="name" value="MavenRepo" />
22
+ <option name="url" value="https://repo.maven.apache.org/maven2/" />
23
+ </remote-repository>
24
+ <remote-repository>
25
+ <option name="id" value="BintrayJCenter" />
26
+ <option name="name" value="BintrayJCenter" />
27
+ <option name="url" value="https://jcenter.bintray.com/" />
28
+ </remote-repository>
29
+ <remote-repository>
30
+ <option name="id" value="Google" />
31
+ <option name="name" value="Google" />
32
+ <option name="url" value="https://dl.google.com/dl/android/maven2/" />
33
+ </remote-repository>
34
+ <remote-repository>
35
+ <option name="id" value="maven" />
36
+ <option name="name" value="maven" />
37
+ <option name="url" value="file:$PROJECT_DIR$/../example/node_modules/react-native/android" />
38
+ </remote-repository>
39
+ </component>
40
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -1,27 +1,27 @@
1
1
  buildscript {
2
- // The Android Gradle plugin is only required when opening the android folder stand-alone.
3
- // This avoids unnecessary downloads and potential conflicts when the library is included as a
4
- // module dependency in an application project.
5
- if (project == rootProject) {
6
- repositories {
7
- google()
8
- jcenter()
9
- }
10
-
11
- dependencies {
12
- classpath("com.android.tools.build:gradle:4.2.2")
13
- }
14
- }
2
+ // The Android Gradle plugin is only required when opening the android folder stand-alone.
3
+ // This avoids unnecessary downloads and potential conflicts when the library is included as a
4
+ // module dependency in an application project.
5
+ if (project == rootProject) {
6
+ repositories {
7
+ google()
8
+ jcenter()
9
+ }
10
+
11
+ dependencies {
12
+ classpath("com.android.tools.build:gradle:7.3.1")
13
+ }
14
+ }
15
15
  }
16
16
  apply plugin: 'com.android.library'
17
17
 
18
18
  def safeExtGet(prop, fallback) {
19
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
19
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20
20
  }
21
21
 
22
22
  android {
23
- compileSdkVersion safeExtGet("compileSdkVersion", 30)
24
-
23
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
24
+
25
25
  compileOptions {
26
26
  sourceCompatibility JavaVersion.VERSION_1_8
27
27
  targetCompatibility JavaVersion.VERSION_1_8
@@ -50,4 +50,4 @@ repositories {
50
50
  dependencies {
51
51
  implementation "com.facebook.react:react-native:+"
52
52
  // implementation "org.jetbrains.trove4j: trove4j: 20160824"
53
- }
53
+ }
@@ -0,0 +1,5 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
@@ -1,2 +1,4 @@
1
1
  android.useAndroidX=true
2
- android.enableJetifier=true
2
+ android.enableJetifier=true
3
+ # https://github.com/facebook/react-native/issues/35168
4
+ org.gradle.jvmargs=-Xmx4096M