Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28474 articles
Browse latest View live

Can't get the entities associated to a connection in TypeORM in React Native

$
0
0

I have been trying for a few days to create a connection with my entities on TypeORM in React Native, but to no avail.This is the code that create the connection.

import {createConnection, getManager, getConnection} from 'typeorm/browser';import MessageSent from '../dbmodels/MessageSent';import Test from '../dbmodels/Test';import User from '../dbmodels/User';import UserEquipment from '../dbmodels/UserEquipment';export default class DBManager {  static async connectDB() {    return await createConnection({      type: 'react-native',      database: 'VRU',      location: 'default',      logging: ['error', 'query', 'schema'],      synchronize: true,      entities: [MessageSent, Test, User, UserEquipment],    });  }  static async saveMessageSent(messageSent) {    console.log('OPTIONS: '+ JSON.stringify(getConnection().options));    await getManager().save(messageSent);  }}

My MessageSent entity is:

import {    Entity,    PrimaryGeneratedColumn,    Column,    ManyToOne} from 'typeorm';import Test from './Test'@Entity()export default class MessageSent {    @PrimaryGeneratedColumn('integer')    id: number;    @Column('varchar',{        length: 20    })    pco_level: string;    @Column('integer')    time_generation_started: number;    @Column('integer')    time_generation_ended: number;    @Column('integer')    time_sent: number;    @Column('varchar')    content: string //TODO ajustar ao tipo pedido pelo CTAG?    @Column('varchar',{        length: 10    })    message_type: string;    @Column('varchar',{        length: 20    })    message_encoding: string;    @Column('varchar',{        length: 10    })    message_status: string;    @Column('varchar')    message_error: string;    @Column('integer')    message_rate: number;    @Column('varchar', {length:10})    flow_direction: string; //Pode ser um enum    //NOTA: A localização foi separada em dois campos porque o TypeORM não suporta os campos geográficos do SQLite (SpatiaLite) e também porque as locations estão definidos como dois campos na documentação de logs     @Column('Double')    latitude: number;    @Column('Double')    longitude: number;    @Column('Double')    speed: number;    @Column('Double')    acceleration: number;    @Column('varchar',{        length: 10    })    communication_protocol: string;    @Column('varchar',{        length: 10    })    security_protocol: string;    @Column('integer')    battery_level: number;    @Column('integer')    battery_consumption: number;    @Column('integer')    cpu_usage: number;    @Column('integer')    ram_usage: number;    @Column('boolean')    app_in_foreground: boolean;    @Column('Test')    @ManyToOne(type => Test, test => test.messagesSent)    //Ver como fazer as chaves estrangeiras    test: Test;}

Everything seems ok. I have checked and rechecked the paths and tried everything I could think of, but the console.log above, when the saveMessageSent function is invoked, returns the following result:

OPTIONS: {"type":"react-native","database":"VRU","location":"default","logging":["error","query","schema"],"synchronize":true,"entities":[null,null,null,null]}

And, of course , the line that saves de entity returns de error:

Possible Unhandled Promise Rejection (id: 0): EntityMetadataNotFound: No metadata for "MessageSent" was found.

Any help would be greatly appreciated.

Thank you.


Video compression for a social media site [closed]

$
0
0

I am trying to create a social media site. I am using React Native (Andriod) for the frontend, and Spring framework and MySQL for the backend. We provide video uploading on my website. What compression algorithms are common in social media sites when compressing video/images, and also do I compress this data in the frontend or backend.

How to correctly trim user input in React Native?

$
0
0

I have TextInput that receives onChangeText as a prop:

<TextInput  ...  value={this.state.myString}  onChangeText={this.updateInput.bind(this)}/>

And updateInput is represented as:

updateInput(newString) {  this.setState({ myString: newString.trim() });}

This works for Android only. Is there some way to trim user input on both platforms (iOS, Android)?

Update

Actually, string is processed as trimmed, but you can still type as many whitespaces as you want on iOS. And if you type two whitespaces in a row the dot appears like it would be the end of the sentence. This is undesirable behaviour, is there a way to avoid it?

Link with example video: https://streamable.com/dzl3c

ANDROID_SDK_ROOT is not defined while running detox test

React Native Expo Android WebView

$
0
0

I'm working on a React Native app using Expo.Trying to load a WebView using "react-native-webview".

this is the WebView element:

<WebView style={styles.container}            source={{ uri: "https://www.google.com/" }}            ref={ref => (this.webview = ref)}            cacheEnabled={false}    />

I'm running the app on devices, on iOS it works well, but on Android it doesn't load the site and I'm getting an Error.

Encountered an error loading page, Object {"canGoBack": false,"canGoForward": false,"code": -1,"description": "net::ERR_CACHE_MISS","loading": false,"target": 25,"title": "","url": "https://www.google.com/",}

Expo version - 3.19.2

Android version - 5.0

Couldn't find a working solution, does anyone know what is missing?

expo react native android clicking screen under stack navigation error

$
0
0

I made an Android App with react-native and expo, and I noticed very weird bug in my app. It is the bug that it is possible to click screen in the stack navigator which is under the current screen.

For example, let's say this is Home screen in stack navigator.

If I push the third tab, which is written "컵", it pushes stack screen in the stack navigator.

After that, If I press certain area of the screen(I marked on the image), it goes to this screen, which is the screen that goes when I press the fourth tab in the home screen which is written "asdf".

My guess is that it happens because pressing screen under the current screen(sharing same stack navigation) is possible. Can anybody help please? ㅠㅠ

Unable to start android react-native app: Error: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT

$
0
0

I'm attempting to get started with a react native project I've inherited.

My steps in running are to:

  1. npx react-native start - this works
  2. Open an android emulator (API 28)
  3. Open a new bash
  4. npx react-native run-android

I get the error:

warn Failed to connect to development server using "adb reverse": spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT info Starting the app on "emulator-5554"... error Failed to start the app. Run CLI with --verbose flag for more details. Error: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT

I'm surprised by the ENOENT, as I can manually run the file at that location:~/Library/Android/sdk/platform-tools/adb

My path was set up as noted in the Development guide: https://reactnative.dev/docs/environment-setup

export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools

Why might it fail on locating ~/Library/Android/sdk/platform-tools/adb?

React native video player not visible, controls are visible , sound also coming out

$
0
0
 *// video get from this*   const SampleVideo = require('../samplevideos/VID_20190811_172946.mp4'); *// this is my app.js code*<View style={{ flex: 1 }}><Video style={{ flex: 1 }} controls={true} source={SampleVideo}            onPress={() => this.togglePaused(this.paused)}            ref={(ref) => {                // this._player = ref            }}></Video></View>

[![I am able hear the sound of the video but it is not visible,

Sound coming out, controls for the video is visible ][tried all the ways to fix unable to find the solution]][ IF anyone help me on this that really appreciates]


(React native) How to use SafeAreaView for Android notch devices?

$
0
0

I'm actually developing an app with react native and i'm testing with my one plus 6 and it has a notch. The SafeAreaView is a solution for the iPhone X but for Android, it seems there is no solution.

Did someone heard about anything to solve this kinf of issue ?

React Native Ask to be Text while the component actually a View

How to set canOverrideExistingModule=true in React Native for Android Apps?

$
0
0

I built an android app using React Native, it got built successfully but when I run the app in my Android Virtual Device it shows up a full red screen with the following error:

enter image description here

I have not done native app development ever before neither do I have any knowledge of Java so I have no idea what this error means and how to fix this.

Re render Header in ReactJs

$
0
0

I have index.js as below code:

<relevant imports>function Header(){       return(<HeaderComponent/>);}ReactDOM.render(<div><Router><div><Switch><Route path="/page1" component={page1} /><Route path="/page2" component={page2} /><Route path="/page3" component={page3} /><Route path="/home" component={PortfolioPageComponent} /><Route path="/" component={WelcomePage} /></Switch></div></Router></div>,    document.getElementById('root'));ReactDOM.render(<Header />, document.getElementById('page-header'));

now when I am opening my app it goes to WelcomePage .In this component I have authorization logic. once Authetication is done, Page is redirecting to PortfolioPageComponent but header component is NOT getting reloaded.

How can I re-render Header component also on each redirection?

Why my WebView in react native says about error?

$
0
0

I have the next modules version:"react": "16.9.0","react-native": "0.61.5","react-native-webview": "^8.0.2",

build.gradle:

buildscript {ext {    googlePlayServicesVersion = "+"    buildToolsVersion = "29.0.3"    minSdkVersion = 16    compileSdkVersion = 29    targetSdkVersion = 29    supportLibVersion = '1.0.0'}repositories {    google()    jcenter()    maven {        url 'https://maven.fabric.io/public'    }}dependencies {    classpath 'com.android.tools.build:gradle:3.4.0'    classpath 'com.google.gms:google-services:4.2.0'    classpath 'io.fabric.tools:gradle:1.31.2'}

}

I used WebView like this: import { WebView } from 'react-native';

Now I'm using: import { WebView } from 'react-native-webview';

const source = {        html: `<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta charset="utf-8"></head><body><p id="mainText" style="position: fixed; top: 0; left: 0; width: 100%; text-align: justify; padding-bottom: 30px; color: #fff; font-size: 16px;                     font-family: Arial, sans-serif; background-color: transparent;">                        ${this.props.children}</p></body></html>        `,    }

...

<WebView     ref={r => (this.webref = r)}     javaScriptEnabled={true}     onLoadEnd={() => this.webref.injectJavaScript(this.state.script)}     showsVerticalScrollIndicator={false}     onMessage={event => {         this.setState({             height: event.nativeEvent.data         })     }}     source={source}     useWebKit={true} />

And I have error ->enter image description here

Please help me with that))

Add button to opened app via Linking on React Native App

$
0
0

i have a case on react native app development :

  • The app opens an external app (eg. Facebook App)
  • When Facebook App was opened, i need to add a floating button or whatever to Facebook App, it will be used for back to my application
  • When that button clicked, it will trigger a function from my react native app

Is it possible ?

What i tried so far is trying to open the app inside a View with WebView and the button that i wanted, but the WebView opens www.facebook.com instead of Facebook App installed.

Video clipping and preview feature in react native iOS

$
0
0

I need a library for react native in which user can capture a video and then select start and end point from video frames between which user wants to clip the video and need preview of that start and end point video.

I had tried React-native-video-processing library it is working for android but in ios it is not working and gives errors related to Swift Version conflict in Xcode.

So is there any suggestions for react native library for above video clipping feature which is compatible with Android and iOS both?


Task 'installDebug' not found in project ':app' while installing react native app in android emulator/device on macOS Catalina

$
0
0

I was trying to install a react native app in Android emulator/device on macOS Catalina using following command

npx react-native run-android

but unable to install it on emulator due to below error

Task 'installDebug' not found in project ':app'.

I already added,android sdk path in .zshrc file, those are as follows

export ANDROID_HOME=$HOME/Library/Android/sdkexport PATH=$PATH:$ANDROID_HOME/emulatorexport PATH=$PATH:$ANDROID_HOME/toolsexport PATH=$PATH:$ANDROID_HOME/platform-tools

but didn't get any success.I know i am missing something major here,but how to install react native app in android emulator/device on MacOS Catalina.

Thanks in Advance.

(React native )After running signed apk undefiend code:-1 error displaying

$
0
0

I have created a react native app after i launched my signed apk after installing it showing . Error loading page Domine undefined Error code :-1Description:net::ERR_ClEARTEXT_Not_Permitedenter image description hereenter image description here

Copy Image to local storage using rn-fetch-blob

$
0
0

I am using react-native-image-picker to get image from the system. As soon as the user selects and image, i am dispatching an redux action and it looks like this.

imgSrc variable contains image URI. I used split and pop to get the image name.But still the image has not been copied from imgSrc to my new generated path.

export const addPlace = (title , address , imgSrc) =>{    return async dispatch => {        const fileName = imgSrc.split('/').pop()        const newPath = RNFetchBlob.fs.dirs.DocumentDir +'/'+ fileName        try{            await RNFetchBlob.fs.cp( imgSrc , newPath)        } catch ( err){            console.log('error')            throw err        }        dispatch({            type : ADD_PLACE ,            placeData : {                title : title,                address : address,                src : newPath            }        })    }}

How to set the splash screen for react-native android

$
0
0

How does one set a splash screen for react-native android, I can't find anything on the topic and I thought it was odd.

Thanks

Unable to join live video session react-native-webview android

$
0
0

I'm working on a live video session app. I have the web version fully working. I'm trying to use that web app url in my react native app using react-native-webview. In ios app I'm able to join the session but I'm not able to join the session in android and getting the attached message while joining.

My dependency versions:

react: 16.9.0

react-native: 0.61.5

react-native-webview: 8.2.1

Message while joining online session in react native android app

Thanks in advance.

Viewing all 28474 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>