Browse Source

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

Hello, in order to use react-native-webview > 6.0.0 please make your android/build.gradle contains:
```
android.useAndroidX=true
android.enableJetifier=true
```
This enables AndroidX libraries which are the new standard.
Thibault Malbranche 5 years ago
parent
commit
fa0489e9b0

+ 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;

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

@@ -12,10 +12,20 @@ $ 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
+Android:
22
+Please make sure AndroidX is enabled in your project by editting `android/gradle.properties` and adding 2 lines:
23
+
24
+```
25
+android.useAndroidX=true
26
+android.enableJetifier=true
27
+```
28
+
19 29
 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 30
 
21 31
 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 +43,8 @@ class MyWeb extends Component {
33 43
   render() {
34 44
     return (
35 45
       <WebView
36
-        source={{uri: 'https://infinite.red'}}
37
-        style={{marginTop: 20}}
46
+        source={{ uri: 'https://infinite.red' }}
47
+        style={{ marginTop: 20 }}
38 48
       />
39 49
     );
40 50
   }