Skip to content

Commit

Permalink
feat(android): Migrate to Android X (#131 by @thedeepanshujain)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: You are required to only use either the Support Library or AndroidX for your dependencies. If you need to migrate this library back to the support library, or another library forward to AndroidX, then take a look at the [Jetifier tool](https://github.com/mikehardy/jetifier).
  • Loading branch information
thedeepanshuj authored and matt-oakes committed Jul 6, 2019
1 parent c353575 commit 7994bc7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ protected List<ReactPackage> getPackages() {
## React Native Compatibility
To use this library you need to ensure you are using the correct version of React Native. If you are using a version of React Native that is lower than `0.57` you will need to upgrade that before attempting to use this library.

| `@react-native-community/netinfo` version | Required React Native Version |
| ----------------------------------------- | ----------------------------- |
| `3.x.x` | `>= 0.59` |
| `2.x.x` | `>= 0.57` |
| `1.x.x` | `>= 0.57` |
| `@react-native-community/netinfo` version | Required React Native Version |
| ----------------------------------------- | --------------------------------------------------------------------------------- |
| `4.x.x` | `>= 0.60` or `>= 0.59` if using [Jetifier](https://github.com/mikehardy/jetifier) |
| `3.x.x` | `>= 0.59` |
| `2.x.x` | `>= 0.57` |
| `1.x.x` | `>= 0.57` |

## Migrating from the core `react-native` module
This module was created when the NetInfo was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:
Expand Down Expand Up @@ -279,6 +280,14 @@ const YourComplement = () => {
## Troubleshooting
### Errors when building on Android
This library was migrated from using the support library to AndroidX in version `4.0.0`. All of your depenencies must be using either the support library *or* AndroidX. Using a mixture of the two is not possible.
From React Native 0.60 AndroidX is used by default.
If you need to either convert this library back to the support library (to use an older React Native version) or convert other libraries forward to use AndroidX (if they have not been updated yet), you can use the [Jetifier](https://github.com/mikehardy/jetifier) tool.
### Errors while running Jest tests
If you do not have a Jest Setup file configured, you should add the following to your Jest settings and create the `jest.setup.js` file in project root:
Expand Down
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ReactNativeNetInfo_compileSdkVersion=28
ReactNativeNetInfo_buildToolsVersion=28.0.3
ReactNativeNetInfo_targetSdkVersion=27
ReactNativeNetInfo_minSdkVersion=16
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v4.net.ConnectivityManagerCompat;
import android.telephony.TelephonyManager;
import androidx.core.net.ConnectivityManagerCompat;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.WritableMap;
Expand Down

0 comments on commit 7994bc7

Please sign in to comment.