Native-Base Component Picker issue - android

The app is crashing while i Load this component in the view. It used to working before.
import {Picker, View} from 'native-base';
<View style={{flex:1}}>
<Picker mode="dropdown">
<Picker.Item label="Select" value={0} />
<Picker.Item label="Veg" value={0} />
<Picker.Item label="Non-Veg" value={0} />
</Picker>
</View>

it seems like native base picker has a dependency for #react-native-community/picker
try to install it via
npm install #react-native-community/picker
npx pod-install
once installed it will fix the issue for you

Related

Loading a static HTML file with React Native Webview on Andriod

I'm a React Native newbie and I'm trying to assess the viability of porting to Android a React Native app that was originally written (not by me...) with iOS in mind.
At the moment I'm not trying to have code that will easily generate both Android and iOS bundles, just having the Android app working properly, with whatever alteration needed. We are using React Native 0.65.3
After setting up the Android environment, I'm compiling it on a MacBook Pro M1 with this command:
npx react-native bundle --entry-file ./index.js --platform android --dev false --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
I got the app to start, up to the point that a Webview has to load a static HTML file that is shipped with the assets (and which executes javascript code on its own)
In the original code, the HTML files to be loaded are located in the component folder (so NOT the usual assets folder). The original code that works for iOS is as follows:
const HTML: { [x: string]: any } = {
app_avatar_1: () => require('../../html/webview/app_avatar_1.html'),
...
};
return (
<View style={styles.container}>
<WebView
ref={webViewRef}
originWhitelist={['*']}
javaScriptEnabled={true}
domStorageEnabled={true}
source={HTML[avatarId]()}
onMessage={onMessage}
/>
</View>
);
Because Webview under Android does not "like" require() for static files, I ended up using 'file:///path/to/static/HTML/file' and adding allowFileAccess={true} as Android by default doesn't allow access to static HTML, JS, etc files.
Frustrated with the various ERR_FILE_NOT_FOUND or alternatively ERR_ACCESS_DENIED, I moved the HTML files in the assets folder of the React project...nothing changes...
At this point, I have no clue where the static HTML files should be located or I could invoke them inside the Webview...
I also noticed that the static files are being copied to the res folder only if there is a require() statement explicitly including those, otherwise they seem to be simply ignored.
With the following code:
const HTML: { [x: string]: any } = {
app_avatar_1: () => require('assets/webview/app_avatar_1.html'),
...
}
<WebView
ref={webViewRef}
originWhitelist={['*']}
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'file:///assets/webview/app_avatar_1.html'}}
allowFileAccess={true}
onMessage={onMessage}
/>
I get a "ERR_ACCESS_DENIED" error.
For whatever reason, static images are displayed correctly with no change required for Android...for instance:
const avatarImages: { [x: string]: ImageSourcePropType } = {
app_avatar_1: require('assets/avatars/thumb-0.jpg'),
....
}
<Image
style={styles.image}
source={avatarImages[el.id]}
resizeMode={'cover'}`
/>
will work on Android right away...
Thank you all the people who will help!
This is how I eventually made it work:
const updateSourceOnLoad = () => {
setRenderedOnce(true);
};
if(Platform.OS === "android") {
return (
<View style={styles.container}>
<WebView
ref={webViewRef}
originWhitelist={['*']}
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'file:///android_asset/file.html'}}
allowFileAccess={true}
allowUniversalAccessFromFileURLs={true}
onMessage={onMessage}
onLoad={updateSourceOnLoad}
/>
</View>
)
}
The issue seems to be the way the Webview sets flags once being loaded (only on Android)

Bug in react-native-vector-icons, Icons is in japanese

I have a react-native app.
I have an app but when i use icons(react-native-vector-icons) the icon show in japanese, example:
The icon that i want to use is "add"
Icon
But when i show the icon on my app that show like this:
bug
The code of this app is:
Code
Code:
const App = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
<Icon name="add" color="#000" size={22} />
</Text>
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
});
React-native Doctor:
Common
✓ Node.js
✓ yarn
Android
✖ JDK
- Version found: 1.8.0_265
- Version supported: >= 8
✖ Android Studio - Required for building and installing your app on Android
✓ Android SDK - Required for building and installing your app on Android
✓ ANDROID_HOME
Errors: 2
Warnings: 0
Usage
› Press f to try to fix issues.
› Press e to try to fix errors.
› Press w to try to fix warnings.
› Press Enter to exit.
got same issue.Follow this instruction :
Edit android/app/build.gradle ( NOT android/build.gradle ) and add the following:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
And rebuild.

React Native WebView video not playing in iOS

I developed mobile app which has video player in react native.
Then I built both Android and iOS app from the react native project.
But it's working well in Android but not playing in iOS.
If you've ever experienced this problem, please help me.
This is code and package information.
<WebView
allowsFullscreenVideo={true}
style={{ aspectRatio: 1.6, backgroundColor: "#000000", flex: 1 }}
source={{ uri: 'https://sample.mp4' }}
/>
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-webview": "^8.0.3",
This code works for me in android and ios
<View style={{ height: 300 }}>
<WebView
style={{flex: 1.0}}
javaScriptEnabled={true}
domStorageEnabled={true}
source={{uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4' }}/>
</View>

using react-native in vue-native

I'm new in app dev and I wanted to start with vue native and as I saw in the documentation,vue native is not able to acces some device API's like local file,but react native can and vue is just wrapper around the React Native,
So how can I use import react native compoment and API's inside vue project?
and use expo to development
For example ionicons:
In script part:
import { Ionicons } from "#expo/vector-icons";
export default {
components: {Ionicons},
}
After that you can use it in template:
<template>
<view class="container">
<ionicons name="md-checkmark-circle" size=92 color="green" />
</view>
</template>
You can see examples here:
https://vue-native.io/docs/community-libraries-doc.html
Another example with Expo-Speech:
Installing package:
expo install expo-speech
Add it in script:
import * as Speech from 'expo-speech';
export default {
methods: {
sayHi: function(){
Speech.speak('Hi');
}
}
}
In template:
<template>
<view class="container">
<button title="Say Hi" :on-press="sayHi" />
</view>
</template>
Good luck!

different code but the output does not change when i test on a device

Hello i am beginner in react native, and i followed all the guides to use react native with native base, but whenever i test the application using the sample codes below, i still get
" welcome to React Native, to get started, edit index.android.js"
as you can see code and output do not match, any idea on how to solve this?
import {Container, Content, Button, Icon} from 'native-base';
import React, {Component} from 'react-native';
​
export default class IconButtonExample extends Component {
render() {
return (
Home
<Button success iconRight>
Next
<Icon name="ios-arrow-forward" />
</Button>
<Button info>
Previous
<Icon name="ios-arrow-back" />
</Button>
<Button warning>
<Icon name="ios-star" />
</Button>
<Button danger>
<Icon name="ios-close-circle" />
</Button>
<Button style={{backgroundColor: '#384850'}} >
<Icon name="ios-search" style={{color: '#00c497'}}/>
</Button>
</Content>
</Container>
);
}
}
you need to put the code you posted above inside the main file named index.android.js
you need to restart your emulator and re-bundle the application
You can see here the default folder structure for react native projects.
or read about it

Categories

Resources