Skip to content

Add gradle backward-compatibility with AndroidX support #97

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

Merged
merged 10 commits into from
Aug 16, 2019
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ in case of vulnerabilities.

## [Unreleased]

## [3.0.1] - 2019-08-16

### Added
- Add gradle backward-compatibility for Android Support with Jetifier ([#96](https://github.com/proyecto26/react-native-inappbrowser/pull/97)).
- Added **androidXAnnotation** and **androidXBrowser** properties from **rootProject.ext** for **AndroidX** with backward compatibility using **supportLibVersion** property instead.

## [3.0.0] - 2019-07-27
### Added
- **Android:** Migrate to AndroidX by [@jdnichollsc](https://github.com/jdnichollsc) ([8a083f2](https://github.com/proyecto26/react-native-inappbrowser/commit/8a083f24847ac5f49923c6217106628434634b4d)).
Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,53 @@

### Mostly automatic installation

#### Using React Native >= 0.60
Linking the package manually is not required anymore with [Autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).

- **iOS Platform:**

`$ cd ios && pod install && cd ..` # CocoaPods on iOS needs this extra step

- **Android Platform for Android Support:**

Using [Jetifier tool](https://github.com/mikehardy/jetifier) for backward-compatibility.

Modify your **android/build.gradle** configuration:
```
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
# Only using Android Support libraries
supportLibVersion = "28.0.0"
}
```

- **Android Platform for AndroidX:**

Modify your **android/build.gradle** configuration:
```
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
# Remove 'supportLibVersion' property and put specific versions for AndroidX libraries
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
// Put here other AndroidX dependencies
}
```

#### Using React Native < 0.60

`$ react-native link react-native-inappbrowser-reborn`

### Manual installation


#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
Expand Down
17 changes: 15 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,21 @@ repositories {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.facebook.react:react-native:+'
implementation 'androidx.annotation:annotation:1.+'
implementation 'androidx.browser:browser:1.+'
implementation 'org.greenrobot:eventbus:3.+'
def supportLibVersion = safeExtGet('supportLibVersion', safeExtGet('supportVersion', null))
def androidXVersion = safeExtGet('androidXVersion', null)
if (supportLibVersion && androidXVersion == null) {
implementation "com.android.support:support-annotations:$supportLibVersion"
implementation "com.android.support:customtabs:$supportLibVersion"
} else {
def defaultAndroidXVersion = "1.+"
if (androidXVersion == null) {
androidXVersion = defaultAndroidXVersion
}
def androidXAnnotation = safeExtGet('androidXAnnotation', androidXVersion)
def androidXBrowser = safeExtGet('androidXBrowser', androidXVersion)
implementation "androidx.annotation:annotation:$androidXAnnotation"
implementation "androidx.browser:browser:$androidXBrowser"
}
}

4 changes: 3 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ buildscript {
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
androidXVersion = "1.+" // Default AndroidX dependency
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
}
repositories {
google()
Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-inappbrowser-reborn",
"version": "3.0.0",
"version": "3.0.1",
"description": "InAppBrowser for React Native",
"main": "index.js",
"readmeFilename": "README.md",
Expand Down Expand Up @@ -45,4 +45,4 @@
"type": "opencollective",
"url": "https://opencollective.com/proyecto26"
}
}
}