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

React-Native assembleRelease fails for task ':app:bundleReleaseJsAndAssets'

$
0
0

When I run ./gradlew assembleRelease build is failed with this error:

Error:Execution failed for task ':app:bundleReleaseJsAndAssets. 
> A problem occurred starting process 'command 'node'

I searched on the internet and found some topics about it, but I couldn't solve my problem.

React-Native version: 0.54.0

EDIT:
Now I'm running ./gradlew assembleRelease --info from the terminal instead of Android Studio and I get different error.
Here is the result:

> Task :app:processReleaseResources
Putting task artifact state for task ':app:processReleaseResources' into context took 0.007 secs.
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Executing task ':app:processReleaseResources' (up-to-date check took 0.035 secs) due to:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':app:processReleaseResources'.
Unable do incremental execution: full task run
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Aapt2QueuedResourceProcessor is using **/Android/sdk/build-tools/26.0.2/aapt2
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
*
*
*
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt


It seems gradle is looking for libs folder in all modules, but there are no libs folders in the node modules. It's true, but I don't know why gradle is looking for libs folder.


React Native app restarts while on background

$
0
0

I updated my react native app to RN 0.61.2 from RN 0.59 few weeks ago, and a while after that, reading that thread: https://github.com/facebook/react-native/issues/26696 made me upgrade to 0.61.5.

Ever since the first update (to 0.61.2), my app keep restarting while on background .

I have a background location tracking, that is working well, and I can see log in app of location calls going through. But then without no crash report (sentry), and while app is still in background, the app goes back to splash screen.

This happens when there is no internet connection, but not on the first call. only after about 10 calls of location updates to server the app restarts.

So far I tested it only on iOS, but it might also happen on Android devices.

Have been fighting with this for weeks...

Need help desperately

Would appreciate any advice

Android react-native deep linking and application embedded browser

$
0
0

I have a react-native application which use deep linking for Android.

Basically I have a working setup, which means that when im testing on a real device if I go to my website page displaying a link mapped by the AndroidManifest.xml, my app is correctly opening when clicking on the link. Same thing when I'm clicking the mapped link directly from Gmail app or Slack, everything works correctly.

However, when I'm going to my website page (which is displaying the mapped link) from the "embedded" Gmail or Slack browser and clicking on the link, the deep link doesn't work and it redirects on the web directly without asking to open the app first.

It seems a strange behaviour for me and after some research I wasn't able to find an explanation or a solution, so anyone have an idea on how to handle this ?

Thank you for your time.

How to create an app with the react-native-generator for a locally running api and connect to it in the emulator?

$
0
0

first I have to say I'm new to api-platform.com.

I followed the getting started documentation and downloaded, unziped and started api platform with docker and created my own entities. There were no problems. Afterwards I wanted to create an smartphone app with the react-native-generator. I got an error message due to TLS certificate. With set NODE_TLS_REJECT_UNAUTHORIZED=0 I could create the app anyway. When I execute the app in the Android emulator I always get the message "Network request failed" even if I can call the api in the Android Chrome browser with the same url from entrypoint.js.

Now to my questions:

  1. is it still possible to access the api with http?
  2. how to correctly create a react-native app with the generator for the locally running api?
  3. do i have to deploy the api in production first so i can create and run the app or how do i have to do this?

Note: On the host (where docker and the emulator are running) I don't have access to the api with http://localhost:8080/api or http://localhost:8000/api at all. As I saw in the source code, there was a change in the configuration that redirects everything to https.

Thanks and Regards

Automatically detect verification code in react native

$
0
0

React Native To automatically Detect Phone number Verification Code

Which api or library can i use to automatically detect a phone number verification code sent as a message in react native ?

React-Native: "FirebaseError: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)"

$
0
0

I'm building a React Native app, currently trying to implement an authentication registration system through Firebase Auth. I've followed a guide/the docs on the website to setup the Firebase config file. I run the app, enter a email and password, when I click the signup button I'm given the follow error below:

FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).

I've search on google for possible fixes yet nothing seems to work. I've initialized Firebase as per the docs/tutorials I've watched. Hopefully someone can shed some light on the matter. I'll include the config file code below, XXXX to replace my actual config info

firebase.js

import * as firebase from 'firebase/app';
import "firebase/auth";

const firebaseConfig = {
  apiKey: "XXXX",
  authDomain: "XXXX",
  databaseURL: "XXXX",
  projectId: "XXXX",
  storageBucket: "XXXX",
  messagingSenderId: "XXXX",
  appId: "XXXX",
  measurementId: "XXXX"
};

firebase.initializeApp(firebaseConfig);

api.js

export function registerUser({email, password}) {
  firebase
    .auth()
    .createUserWithEmailAndPassword(email, password)
    .catch(function(error) {
      console.log(error);
    });
};

How to make android app available on chromebook (react-native)

$
0
0

I have a react-native android app in the play store. It works on tablet and phone but for some reason it seems unavailable on chromebook. When I go into my playstore account and have a look at supported devices the chromebook is there. I have deleted the play store storage and cache and restarted the device and still the app isnt there. When I link into the app it says that the app is not supported on the device.

react-native android error Failed to install the app native_modules.gradle' line: 170

$
0
0

running react-native run-android in windows but get this error:

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 :ReactNative:Unexpected empty result of running 'npx --quiet --no-install react-native config' command from 'null' directory. :ReactNative:Running 'npx --quiet --no-install react-native config' command from 'null' directory failed.

FAILURE: Build failed with an exception.

  • Where: Script '/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 170

  • What went wrong: A problem occurred evaluating script.

    Command config unrecognized. Make sure that you have run npm install and that you are inside a react-native project.


How to change remote push notification icon for React Native(android) application

How do I get onresume event from React-Native?

$
0
0

How do I get onresume event from React-Native? I want to do some check when Android main activity resumed. I check source code of RN, but it seems no event when app resumed.

Unexpected reserved type number [closed]

$
0
0

I have problems using the library

react-native-wheel-picker.

Is there any way to fix it

Thanks

error image

How to setup the react native navigation on android?

$
0
0

I have some issue with WIX react native navigation when I installed them, I'm doing the steps in the documentation correctly but when running the app and Configure the libs and when up to Configure react native vector icon, I have " Build Failed ".

> Configure project :react-native-vector-icons
The CompileOptions.bootClasspath property has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the CompileOptions.bootstrapClasspath property instead.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex Unable to merge dex

so I don't Know what's wrong, please if you have the same issue and fixed them, help me

ART library does not work in react native

$
0
0

I try to use ART library in react-native build in android phone, but no matter what I put in Shape aways rendering a black image, like this:

enter image description here

My code:

import React from 'react';
import {
ART,
StyleSheet,
View,
Button,
} from 'react-native';

const {
Group,
Shape,
Surface,
} = ART;


export default class App extends React.Component {
    render() {
        return (
        <View style={styles.container}>
            <Surface width={500} height={500}>
                <Group x={0} y={0}>
                    <Shape
                      d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80"
                      stroke="#555"
                      strokeWidth={1}
                     />
                </Group>
            </Surface>
        </View>
        );
    }
}

Big error(s) during cmd's "react-native run-android" command

$
0
0

Si i've been trying to start learning react-native but i encoutered the following error during the execution of the project:

C:\WINDOWS\system32>cd projeto

C:\Windows\System32\projeto>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 6 workers...
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :app:mergeDebugResources FAILED
10 actionable tasks: 2 executed, 8 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> 8 exceptions were raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 15s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> 8 exceptions were raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.

  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\projeto\android\app\build\intermediates\res\merged\debug: error: directory does not exist.



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 15s

    at checkExecSyncError (child_process.js:603:11)
    at execFileSync (child_process.js:621:15)
    at runOnAllDevices (C:\Windows\System32\projeto\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (C:\Windows\System32\projeto\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at C:\Windows\System32\projeto\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Command.handleAction (C:\Windows\System32\projeto\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:164:9)

To clarify things:

1° I followed the installation tutorial in https://docs.rocketseat.dev/ambiente-react-native/android/windows
2° These are my PC specs https://imgur.com/a/jdcUMVd
3° I had at some point to rename my user folder because my name had "Not allowed characters", that is, accents

Also my apoligies for any grammatic mistakes and/or too big post, I've been trying to google this problem for 3 days now and i'm desperate.

React Native two drawers on one screen

$
0
0

I have an app that needs to be able to use two drawer navigators, one on the left and on on the right side of the header.

I am at the point where I can get both drawers to open with the slide gesture, however I need to be able to open it programmatically. I have found the navigation.openDrawer() function only works with one of the drawers and not the other because it is only able to use one of the navigation props (whichever comes first) from my drawer navigators.

Below are my rendering functions:

const LeftStack = createStackNavigator(
  {
    LeftDrawerStack
  },
  {
    navigationOptions: ({navigation}) => ({
      headerLeft: (<TouchableOpacity onPress={() => navigation.openDrawer()}><Icon style={{marginLeft: 10}} name='menu'/></TouchableOpacity>
      )
    })
  }
);

const RightStack = createStackNavigator(
  {
    RightDrawerStack
  },
  {
    navigationOptions: ({navigation}) => ({
      headerRight: (<TouchableOpacity onPress={() => navigation.openDrawer()}><Icon style={{marginRight: 10}} name='ios-bulb'/></TouchableOpacity>
      )
    })
  }
);

export const RouteStack = createStackNavigator(
  {
    screen: LoginScreen,
    navigationOptions: ({navigation}) => ({
      header: null
    }),
    LeftStack,
    RightStack
  }
);

and here are my drawer routes:

export const LeftDrawerStack = createDrawerNavigator(
  {
    Dashboard: {
      screen: DashboardScreen
    },
    History: {
      screen: HistoryScreen
    },
    Privacy: {
      screen: PrivacyPolicyScreen
    },
    TermsAndConditions: {
      screen: TermsAndConditionsScreen
    }
  }, {
    initialRouteName: 'Dashboard',
    contentComponent: LeftDrawerScreen
  }
);

export const RightDrawerStack = createDrawerNavigator(
  {
    LeftDrawerStack,
    Settings: {
      screen: SettingsScreen
    }
  }, {
    drawerPosition: 'right',
    contentComponent: RightDrawerScreen
  }
);

Here is a picture of what I have the navigation looking like so far, however both of the hamburger menus are opening up the same menu on the right instead of one menu on their respective sides.

layout picture

I may be missing some parts but I will be sure to post more info if I forgot any!


Set android alarms in react native

$
0
0

I'm pretty new to react native and I would like to programatically set the android (I don't need this for ios) native alarms (those who can ring even if the phone is off). I already searched but I only found push notifications working like alarms (it can ring, but not if the phone is off). Is it possible, and if yes, how ? If it is possible, not in java, I don't know this language.

Thank you in advance

How to get the marquee effect with Flat list in react native?

$
0
0

I am newbie to react-native. I have to create a marquee effect with list of data. So I have list of brands and those are getting move from left to right. I have to create animation like this. Can anyone please share any example code with flat list.I just tried How to get the marquee effect with list view in react native? But it is not worked for me since ListeView gets deprecated.

React Native : Native modules return nothing

$
0
0

I'm new to React Native and I want to call native modules to get some strings from Android . I write the code like this:

@ReactMethod
public String getToken() {
    String token = "";
    //then take the token
    Log.i("getToken:", token);
    return token;
}

Then use in js.

var tokenString = thismodule.getToken();

However ,when i call the method in js. I can see the correct log " I/getToken : palapalapala " in logcat , but js can't get anything.

So , what's the correct code of this?

Custom Alert control in react-native

$
0
0

I am developing react-native app and trying to make a custom alert method (like Alert. alert() as given in Official site of react-native). React-native alert has no styling property for Font Size and back-ground Color, alert is very small when i'm using on android tab but it's work fine while on using in android scanner and mobile.

enter code here

import React, { Component } from 'react';
import { StyleSheet, Platform, View, Text,TouchableOpacity } from 'react-native'; 
// import PropTypes from 'prop-types';
// import Dialog from "react-native-dialog";
 import Alertfunction from './src/CustomAlert'




 export default class App extends Component{

    render() {

      return (

        <Alertfunction Title={"Alert"} FontSize = {30} FontColor= '#FF9800'  Visible={true}/>


      );
    }
  }


const styles = StyleSheet.create({

 MainContainer :{

  flex:1,
  paddingTop: (Platform.OS) === 'ios' ? 20 : 0,
  alignItems: 'center',
  justifyContent: 'center',

  }

});





customAlert.js



import React, { Component } from 'react';
import { StyleSheet, Platform, View, Text,TouchableOpacity } from 'react-native'; 
import PropTypes from 'prop-types';
import Dialog from "react-native-dialog";

class Alertfunction extends Component {
    state = {
        dialogVisible: this.props.Visible
      };

      showDialog = () => {
        this.setState({ dialogVisible: this.props.Visible });
      };

      handleCancel = () => {
         this.setState({ dialogVisible: false });
        // this.props.Visible=false;
      };

      handleDelete = () => {
         this.setState({ dialogVisible: false });
        //this.props.Visible=false;
      };

  render() {

    return (

            <View>
                <TouchableOpacity onPress={this.showDialog}>
                <Text >{this.props.Title}</Text>
                </TouchableOpacity>
                <Dialog.Container visible={this.state.dialogVisible}>
                <Dialog.Title style={{fontSize : this.props.FontSize, color: this.props.FontColor}}>{this.props.Title}</Dialog.Title>
                <Dialog.Description style={{fontSize : this.props.FontSize, color: this.props.FontColor}}>
                    Do you want to delete this account? You cannot undo this action.
                </Dialog.Description>
                <Dialog.Button style={{fontSize : this.props.FontSize, color: this.props.FontColor}} label="Cancel" onPress={this.handleCancel} />
                <Dialog.Button style={{fontSize : this.props.FontSize, color: this.props.FontColor}} label="ok" onPress={this.handleDelete} />
                </Dialog.Container>
            </View>

    );
  }
 }

export default Alertfunction;
Alertfunction.propTypes =
{
    Title: PropTypes.string,
  FontSize: PropTypes.number,
  FontColor: PropTypes.string,
  Visible: PropTypes.bool,

}

Alertfunction.defaultProps =
{
    Title: "Default Name",
  FontColor: "#00E676",
  FontSize: 15,
  Visible:false
}

const styles = StyleSheet.create({

 MainContainer :{

  flex:1,
  paddingTop: (Platform.OS) === 'ios' ? 20 : 0,
  alignItems: 'center',
  justifyContent: 'center',



  }

});

React Native Expo audio player error - Player does not exist

$
0
0

I'm using react native expo audio in my app, I use createAsync to load the audio in the player but sometimes i get Player doesn't exist error and sometimes it works fine. I'm unable to debug the error. I've also tried expo loadAsync to create and load the audio, it also produces the same error. Heres my code...

    componentWillMount(){
        const audioFileLocation = audioFile;
        const source = audioFileLocation;
        const { sound } = await Audio.Sound.createAsync(
            source,
            {
                progressUpdateIntervalMillis: 1000,
                shouldPlay: false,
                isLooping: false,
            },
            onPlaybackStatusUpdate,
        );
        return sound;Ï
    }

export const playAndPauseSound = async (playbackStatus, playbackInstance) => {
    if (playbackStatus.isPlaying) {
        await playbackInstance.pauseAsync();
    } else {
        if (playbackStatus.positionMillis === playbackStatus.durationMillis) {
            return playbackInstance.replayAsync();
        } else {
            return playbackInstance.playAsync();
        }
    }
}
Viewing all 28476 articles
Browse latest View live


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