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

Failed to launch emulator. Reason: Emulator exited before boot en React Native when react-native run-android

$
0
0

I am installing Reac Native according to this website https://medium.com/@leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea, its very useful until I run the command react-native run-android, this is the error what I recive

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 8 workers... info Starting JS server... info Launching emulator... error Failed to launch emulator. Reason: Emulator exited before boot..

Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings 24 actionable tasks: 4 executed, 20 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

    Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

  • 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 7s

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:transformNativeLibsWithMergeJniLibsForDebug'.

    Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

  • 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 7s

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\JesusApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)

My node version is 10, and I am working on windows, please help, thank you.


React Native gradle executionHistory.bin too big

$
0
0

I've recently upgraded my react-native app to version 0.60.5, as to fulfil App Store requirement of 64-bit app, but I've noticed that the executionHistory.bin file inside android/.gradle/x.x.x/executionHistory got really big, going from ~6Mb, to ~100Mb, which is a real pain as GitHub won't allow files larger than 100Mb to be uploaded. I searched a way to clean the file, delete it and recreate it but really haven't found much. I want to know how to solve this issue, if I screw up upgrading my rn version or something.

Specs:

OS:
macOS Catalina
version: 10.15.1

React-Native: 0.60.5

React Native Deep Linking

$
0
0

I have the following block running on compontentDidMount to detect incoming deep links from a web browser.

    // Search for deep links
    if (Platform.OS === 'android') {
      Linking.getInitialURL().then((url) => {
        this.navigate(url);
      });
    } else {
      Linking.addEventListener('url', this.handleOpenURL);
    }

My problem is whenever I click a link with the app running in the background, I need to be able to detect the newly clicked link.

i have this function running:

handleAppStateChange = (nextAppState) => {
    if (nextAppState === 'active') {
     if (Platform.OS === 'android') {
       Linking.getInitialURL().then((url) => {
         this.navigate(url);
       });
     } else {
       Linking.addEventListener('url', this.handleOpenURL);
     }
    }
  }

However this loads whatever link that was clicked to trigger the app to load in the first place.

Can anyone help me identify how to detect a link clicked in the browser with the app running in the background?

How to Force React Native app to be just RTL?

$
0
0

I have an app is written in react native and all things in the app use "Arabic Language and layout"

So I want to force the app to be RTL & Layout too, so I use I18nManager from RN to do it and it's work fine in debugging version "when my mobile language LTR OR RTL it's work perfectly"

/**
 * @format
 */

import {AppRegistry, I18nManager} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

I18nManager.forceRTL(true);

AppRegistry.registerComponent(appName, () => App);

but when I release a apk version for play store when my mobile language RTL "Arabic" the layout and other things works fine, BUT when my mobile language be LTR "English" the layout changes and all of things

SO i want to force my app to be RTL whether the mobile language "Arabic or English"

React-Native :java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so

$
0
0

I have just updated my project to use react-native version 0.60.2 . But when I am trying to run an application on Android device it gets crashed after launch screen. I got the following error logs :

E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.tjspeed, PID: 3909
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
        at java.lang.Thread.run(Thread.java:760)

Few suggestions available here : https://github.com/facebook/react-native/issues/25601 but unfortunately none of them worked for me. Please suggest the workaround.

How do I add these dependencies?

$
0
0

I am very new to React Native. I am trying to install react-native-router-flux on my project following this website

https://github.com/aksonov/react-native-router-flux

One of the steps refers to users with React Native 0.60 and higher. For android users it says to "add the following two lines to dependencies section in android/app/build.gradle:"

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

Although I don't know how to do this Could you please help me?

react-native cross platform work on Android | Ios and web?

$
0
0

i know that react-native allows to code in android and ios at the same time , but does it allow to code the web version ?

Exemple:

My application on android and ios is : test123

My application on a website is : test123.com

So I would like to know if I code in react-native, if there is also a web version to put it on a website?

If yes :

1 - How to configure our react-native application with our website?

2- How to test my application on my website while I code ?

If no:

Is there a solution to quickly code in web version what we did with react-native?

Thank you!

Testing android.emu.release in travis (Detox): -read-only error

$
0
0

I'm trying to set up travis CI for my application with Detox as the test suite. I'm close to achieving the final setup, but I'm currently stuck on the following error which occurs during the final step of the build (testing phase, since the android.emu.release configuration builds successfully, though slowly).

detox[6708] ERROR: [Emulator.js/SPAWN_FAIL] unknown option: -read-only

npx detox test --headless -c android.emu.release --gpu swiftshader --cleanup
detox[6696] INFO:  [test.js] configuration="android.emu.release" cleanup=true gpu="swiftshader" headless=true reportSpecs=true readOnlyEmu=false DETOX_START_TIMESTAMP=1578027757256 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --maxWorkers 1 "e2e"
detox[6708] INFO:  [DetoxServer.js] server listening on localhost:38035...
detox[6708] ERROR: [Emulator.js/SPAWN_FAIL] `/usr/local/android-sdk/tools/emulator -verbose -no-audio -no-boot-anim -no-window -read-only -port 17944 @pixel9 -gpu swiftshader` failed with code 1
  err: ChildProcessError: `/usr/local/android-sdk/tools/emulator -verbose -no-audio -no-boot-anim -no-window -read-only -port 17944 @pixel9 -gpu swiftshader` failed with code 1
      at ChildProcess.<anonymous> (/home/travis/build/uva-cp-1920/PowerShare/src/PowerShare/node_modules/child-process-promise/lib/index.js:132:23)
      at ChildProcess.emit (events.js:305:20)
      at maybeClose (internal/child_process.js:1028:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
detox[6708] ERROR: [Emulator.js/SPAWN_FAIL] unknown option: -read-only
please use -help for a list of valid options
detox[6708] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR]

For reference, below is my .travis.yml file:

#before_install:

env:
  global:
    - NODE_VERSION=stable


matrix:
  include:

    - language: android
      cache: yarn
      jdk: oraclejdk8
      dist: trusty
      sudo: required
      android:
        components:
          - build-tools-28.0.3
          - android-28
          - sys-img-x86-android-28


      install:
      - echo no | android create avd --force -n pixel9 -t android-28 --abi default/x86
      - curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
      - sudo apt-get install -y nodejs

      script:
      - cd src/PowerShare/
      - yarn
      - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
      - npx detox build -c android.emu.release
      - npx detox test --headless -c android.emu.release --gpu swiftshader --cleanup

I'm using the latest node version (13.5.0), react native is 0.61.2, and Detox is 14.9.2. Also, if anyone has any suggestions on how to speed up my build (currently takes around ~8 minutes for a full build), that would be appreciated as well!


How can I use the image uploaded using ImagePicker in expo as it saves in cache and it doesn't show in other places ,

$
0
0

When we use ImagePicker , it stores data in the cache directory which can't be relied upon. I want to use the uploaded image at several places in my app but when I use the uri , It doesn't changes.

React Native - Navigate from screen with status bar to full screen

$
0
0

I have 2 screens in my app, one with status bar and one without status bar. 1st screen is full screen(without status bar) which contains button to navigate to 2nd screen which is with status bar.

1st screen code to hide status bar:

render(){ return ( ); }

When I jump to 2nd screen from 1st and press back button on 2nd screen, 1st screen flickers(UI gets rearranged from status bar to full screen) layout as it hides status bar which is not hidden in 2nd screen. So ultimately, for a fraction of time, UI looks cracky.

I have tried to hide status bar on back press of 2nd screen but then it flickers UI of 2nd screen. Is there any work around to resolve this issue?

Any help will be appreciated!

React native(android) assembleRelease gets bundle assembling error

$
0
0
{
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "load-script": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.7.1",
    "axios": "^0.18.0",
    "native-base": "^2.12.1",
    "prop-types": "^15.7.2",
    "react": "16.8.3",
    "react-native": "0.59.5",
    "react-native-extended-stylesheet": "^0.11.1",
    "react-native-gesture-handler": "1.4.0",
    "react-native-image-slider": "^2.0.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-snap-carousel": "^3.8.4",
    "react-navigation": "^3.11.1",
    "react-redux": "^7.1.3",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "7.4.4",
    "@babel/runtime": "7.4.4",
    "babel-jest": "24.7.1",
    "eslint-config-rallycoding": "^3.2.0",
    "jest": "24.7.1",
    "jetifier": "^1.6.5",
    "metro-react-native-babel-preset": "0.54.0",
    "react-test-renderer": "16.8.3",
    "redux-devtools": "^3.5.0",
    "remote-redux-devtools": "^0.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

//build.gradle android
    buildscript {
        ext {
            buildToolsVersion = "28.0.3"
            minSdkVersion = 16
            compileSdkVersion = 28
            targetSdkVersion = 28
            supportLibVersion = "28.0.0"
        }
    }

i ran .\gradlew assembleRelease and it crashed after that i ran the same command with --info and this is what it's showing me i've tried upgrading and down grading and removing some of unused libs but nothing changed.

> Task :app:bundleReleaseJsAndAssets
Caching disabled for task ':app:bundleReleaseJsAndAssets' because:
  Build cache is disabled
Task ':app:bundleReleaseJsAndAssets' is not up-to-date because:
  Task has failed previously.
Starting process 'command 'cmd''. Working directory: C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app Command: cmd /c node node_modules/react-native/cli.js bundle --platform android --dev false --reset-cache --entry-file index.android.js --bundle-output C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\assets\react\release\index.android.bundle --assets-dest C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\android\app\build\generated\res\react\release
Successfully started process 'command 'cmd''
warning: the transform cache was reset.
error The resource `C:\Users\MOBILE1\Desktop\Gitlab-Devloper-Branch\dev-branch\build-apk-error-last\mbz-mobile-app\index.android.js` was not found.. Run CLI with --verbose flag for more details.

> Task :app:bundleReleaseJsAndAssets FAILED
:app:bundleReleaseJsAndAssets (Thread[Execution worker for ':' Thread 6,5,main]) completed. Took 3.955 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.

i also get uses or overrides a deprecated API and Deprecated Gradle features were used, making it incompatible with Gradle 6.0 for react-native-gesture-handler in android studio. i get

Everytime I install react-navigation my project stops working

$
0
0

I'm trying to use react-navigation with my react-native project. The project will work up until I install react-navigation. After I install it when I try to run my app using a virtual device I keep getting an error when I try to use the command react-native run-android. I'm not sure what happened, but it was working just fine before installing react-navigation. Below is the error i'm getting after I try to start it.

react-native start bundler after using react-native run-android

Any help will be greatly appreciated

React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH

$
0
0

I've followed step by step the official Getting Started. I started from a clean linux install and installed everything required as per the "Building Projects with Native Code" tab. I have also read the troubleshooting section. I've already created the project using the terminal.

This is the error when I run react-native run-android:

    Starting JS server...
    Building and installing the app on the device (cd android && ./gradlew installDebug)...

    ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation.

    Could not install the app on the device, read the error above for details.
    Make sure you have an Android emulator running or a device connected and have
    set up your Android development environment:
    https://facebook.github.io/react-native/docs/android-setup.html

It does not find JAVA_HOME because the latest versions of Android Studio don't require Java to be installed in the system. Instead an internal JRE is used.

Duplicate disclaimer: I've already read this question. This is not what I want. I know how to set the Java home. I just want to run the react project WITHOUT having to install a separate Java.

Questions:

  1. How could I find the internal Java inside the Android Studio folder so that I could point JAVA_HOME to it?
  2. If not possible, could I open and run the project inside the android folder with Android Studio? How would I refresh this project after modifying the React JavaScript code in the parent folder?

Android Studio complains duplicate class

$
0
0

I'm trying to generate an apk file but android studio is showing me the following error:

Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0) Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0) Duplicate class com.google.android.gms.ads.identifier.AdvertisingIdClient$zza found in modules classes.jar (com.google.android.gms:play-services-ads-identifier:17.0.0) and classes.jar (com.google.android.gms:play-services-analytics:7.8.0)

It was working previously. I totally did not make any changes to the code. Can anyone help?

Here is my build.gradle file:

apply plugin: "com.android.application"

import com.android.build.OutputFile

def jscFlavor = 'org.webkit:android-jsc:+'


def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.step_by_step.virq"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }

    }
}
}

dependencies {
implementation project(':react-native-push-notification')
implementation project(':react-native-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation "com.google.android.gms:play-services:7.8.0"

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}
}

task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform- 
android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: "com.google.gms.google-services"

Get device screen height in React Native when Full Screen Gesture feature is enabled and the device have a Notch

$
0
0

I need to get the real screen height of devices that have enabled the Full Screen Gesture feature and have a notch.

The thing is that both of this device features can be modified by users, I mean enabling/disabling Full Screen Gesture and enabling the notch hiding.

I've tried using functions of "Dimensions" class of React Native without results.

How can I detect if these features are enabled on the current device to properly adapt the height of the screen?

Example of Full Screen Gesture in Xiamomi Redmi 7


Face Manipulation with react native

$
0
0

We need to integrate a feature in our app that would detect the face of the user and apply makeup on their face.

For ex. We have a particular shade of lipstick that a customer could apply on their lips to see how it looks.

Is this possible through react native? If not then what would you recommend for this?

React Native & Android?

$
0
0

I'm contemplating on using React Native for a new web app. Is it possible to ship both iOS and Android apps using it?

I know that it's on the roadmap, but it's unclear to me whether it's going to be a separate open-source project (e.g., React Android vs React Native), or just one (e.g., React Native).

Unable to connect with remote debugger

$
0
0

I'm using React.JS and when I do react-native run-android (with my device plugged in) I see a blank page. When I shake the device and select Debug JS Remotely from the option list I see the following screen.

enter image description here

FYI:

OS: Ubuntu 16.04
Node version is: v4.6.2
java version "1.8.0_111"
react": "15.4.1
react-native": "0.38.0

SocketTimeOutException with Expo

$
0
0

I tried to test my first app on my Android phone, but after scanning, I receive the following error message:

" Uncaught error: java.error.sockettimeoutexception: failed to connect to 192.xxx.x.xx (port 19000) from 192.xxx.x.xx (port 45513) after 10000ms "

I already tried to open the firewall settings for port 19000, but that does not seem to be the problem, because it is not fixing my problem. I also closed the virtual network from virtualbox.

Can someone help me?

use ExoPlayer in React Native

$
0
0

Hi I'm using react native, so I needed exoplayer to show subtitle on it in android.... I added exoplayer inside my app, after that should I do something to use exoplayer as default or it will link to react-native-video ? thanks

Viewing all 29659 articles
Browse latest View live


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