I’m working with React Native and I’m using Webview from ‘react-native-webview’.
import React, { useEffect } from 'react'
import { Text, SafeAreaView } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import WebView from 'react-native-webview';
import { styles } from '../theme/appTheme';
export const AtmungBienenflugScreen = () => {
const navigator = useNavigation();
useEffect( () => {
navigator.setOptions({
title:'',
headerTintColor: 'black',
})
})
return (
<SafeAreaView style={styles.container}>
<Text style={ styles.titleLekt}>2.4 Bienenflug</Text>
<WebView
style= { styles.video }
autoPlay
playsInline
source={{ uri: 'https://www.youtube.com/watch?v=QzqmlgnSE38' }} />
</SafeAreaView>
)
}
On IOS is working fine, but on Android is not, shows this error on the terminal:
Encountered an error loading page {“canGoBack”: false, “canGoForward”:
false, “code”: -2, “description”: “net::ERR_NAME_NOT_RESOLVED”,
“loading”: false, “target”: 789, “title”: “”, “url”:
“https://www.youtube.com/watch?v=QzqmlgnSE38”}
And displaying this error on emulator:
Error loading page Domain: undefined Error code: -2 Description:
net::ERR_NAME_NOT_RESOLVED
Does someone have an idea what’s the problem there?
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application
android:usesCleartextTraffic="true">
</application>
Make sure the emulator or device you’re testing on has internet access. Sometimes the Android emulator has network issues. You can try restarting the emulator, checking your network settings, or ensuring that the emulator is not in airplane mode.
import React, { useEffect } from 'react';
import { Text, SafeAreaView } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import WebView from 'react-native-webview';
import { styles } from '../theme/appTheme';
export const AtmungBienenflugScreen = () => {
const navigator = useNavigation();
useEffect(() => {
navigator.setOptions({
title: '',
headerTintColor: 'black',
});
}, [navigator]);
return (
<SafeAreaView style={styles.container}>
<Text style={styles.titleLekt}>2.4 Bienenflug</Text>
<WebView
style={styles.video}
autoPlay
playsInline
source={{ uri: 'https://www.youtube.com/watch?v=QzqmlgnSE38' }}
onError={(syntheticEvent) => {
const { nativeEvent } = syntheticEvent;
console.warn('WebView error: ', nativeEvent);
}}
cacheEnabled={false}
cacheMode={'LOAD_NO_CACHE'}
/>
</SafeAreaView>
);
}