Browse Source

fix(AndroidX support): Fixed broken import + added instructions (#583)

Hello, in order to use react-native-webview > 6.0.2 please make your android/gradle.properties contains:
```
android.useAndroidX=true
android.enableJetifier=true
```
This enables AndroidX libraries which are the new standard.

fixes #580 
fixes #581 
fixes #582
Thibault Malbranche 5 years ago
parent
commit
585ac7a243
No account linked to committer's email address

+ 1
- 0
README.md View File

@@ -30,6 +30,7 @@ This project follows [semantic versioning](https://semver.org/). We do not hesit
30 30
 
31 31
 Current Version: ![version](https://img.shields.io/npm/v/react-native-webview.svg)
32 32
 
33
+- [6.0.**2**](https://github.com/react-native-community/react-native-webview/releases/tag/v6.0.2) - Update to AndroidX. Make sure to enable it in your project's `android/gradle.properties`. See [Getting Started Guide](docs/Getting-Started.md).
33 34
 - [5.0.**1**](https://github.com/react-native-community/react-native-webview/releases/tag/v5.0.0) - Refactored the old postMessage implementation for communication from webview to native.
34 35
 - [4.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v4.0.0) - Added cache (enabled by default).
35 36
 - [3.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v3.0.0) - WKWebview: Add shared process pool so cookies and localStorage are shared across webviews in iOS (enabled by default).

+ 1
- 2
android/gradle.properties View File

@@ -1,5 +1,4 @@
1 1
 ReactNativeWebView_kotlinVersion=1.3.11
2 2
 ReactNativeWebView_compileSdkVersion=28
3 3
 ReactNativeWebView_buildToolsVersion=28.0.3
4
-ReactNativeWebView_targetSdkVersion=28
5
-android.useAndroidX=true
4
+ReactNativeWebView_targetSdkVersion=28

+ 1
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java View File

@@ -10,7 +10,7 @@ import android.graphics.Color;
10 10
 import android.net.Uri;
11 11
 import android.os.Build;
12 12
 import android.os.Environment;
13
-import android.support.annotation.RequiresApi;
13
+import androidx.annotation.RequiresApi;
14 14
 import android.text.TextUtils;
15 15
 import android.view.Gravity;
16 16
 import android.view.View;

+ 14
- 3
docs/Getting-Started.md View File

@@ -12,10 +12,21 @@ $ yarn add react-native-webview
12 12
 
13 13
 React Native modules that include native Objective-C, Swift, Java, or Kotlin code have to be "linked" so that the compiler knows to include them in the app.
14 14
 
15
-This module does not require any extra step after running the link command 🎉
16 15
 ```
17 16
 $ react-native link react-native-webview
18 17
 ```
18
+
19
+iOS:
20
+This module does not require any extra step after running the link command 🎉
21
+
22
+Android:
23
+Please make sure AndroidX is enabled in your project by editting `android/gradle.properties` and adding 2 lines:
24
+
25
+```
26
+android.useAndroidX=true
27
+android.enableJetifier=true
28
+```
29
+
19 30
 For Android manual installation, please refer to [this article](https://engineering.brigad.co/demystifying-react-native-modules-linking-964399ec731b) where you can find detailed step on how to link any react-native project.
20 31
 
21 32
 For iOS, while you can manually link the old way using [react-native own tutorial](https://facebook.github.io/react-native/docs/linking-libraries-ios), we find it easier to use cocoapods.
@@ -33,8 +44,8 @@ class MyWeb extends Component {
33 44
   render() {
34 45
     return (
35 46
       <WebView
36
-        source={{uri: 'https://infinite.red'}}
37
-        style={{marginTop: 20}}
47
+        source={{ uri: 'https://infinite.red' }}
48
+        style={{ marginTop: 20 }}
38 49
       />
39 50
     );
40 51
   }