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

Expo React Native App crashing on android

$
0
0

Ever since I started programming in React Native with Expo, I have been using an ios physical device together with Expo app. I never had any major issues.

Now i wanted to start fixing any bugs on android, but when running the Expo app on my android physical device the Expo app crashes (shuts down) while downloading bundle. It doesn't print any errors into my console, so i don't even know where to start...

Here is my app.json:

{"expo": {"name": "PointoUserApp","slug": "PointoUserApp","version": "1.0.0","platforms": ["ios","android","web"    ],"orientation": "portrait","icon": "./assets/Images/icon.png","splash": {"image": "./assets/Images/splash.png","resizeMode":"contain","backgroundColor": "#ffffff"    },"updates": {"fallbackToCacheTimeout": 0    },"assetBundlePatterns": ["**/*"    ],"ios": {"bundleIdentifier": "com.meretc23.PointoUserApp"    },"android":{    },"web": {"favicon": "./assets/Images/favicon.png"    }  }}

notice it is empty under android because i dont know what is required.

Below is my package.json file as well.

{"main": "node_modules/expo/AppEntry.js","scripts": {"start": "expo start","android": "expo start --android","ios": "expo start --ios","web": "expo start --web","eject": "expo eject"  },"dependencies": {"@expo-google-fonts/inter": "^0.1.0","@fortawesome/fontawesome-svg-core": "^1.2.30","@fortawesome/free-brands-svg-icons": "^5.14.0","@fortawesome/free-solid-svg-icons": "^5.14.0","@fortawesome/react-native-fontawesome": "^0.2.5","@ionic/react": "^5.3.1","@react-native-community/art": "^1.2.0","@react-native-community/async-storage": "~1.11.0","@react-native-community/datetimepicker": "2.4.0","@react-native-community/masked-view": "0.1.10","@react-navigation/bottom-tabs": "^5.7.3","@react-navigation/material-top-tabs": "^5.2.16","@react-navigation/native": "^5.7.2","@react-navigation/stack": "^5.8.0","@types/react-native-snap-carousel": "^3.8.2","core-js": "^3.6.5","expo": "^38.0.0","expo-constants": "~9.1.1","expo-font": "~8.2.1","expo-linking": "^1.0.3","expo-localization": "~8.2.1","expo-location": "~8.2.1","expo-permissions": "~9.0.1","expo-status-bar": "^1.0.0","firebase": "^7.21.1","geolib": "^3.3.1","i18n-js": "^3.7.1","react": "16.11.0","react-dom": "16.11.0","react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz","react-native-check-box": "^2.1.7","react-native-gesture-handler": "~1.6.0","react-native-localize": "^1.4.1","react-native-map-clustering": "^3.3.9","react-native-map-link": "^2.7.17","react-native-maps": "0.27.1","react-native-modal": "^11.5.6","react-native-picker-select": "^8.0.0","react-native-progress": "^4.1.2","react-native-progress-circle": "^2.1.0","react-native-qrcode-svg": "^6.0.6","react-native-reanimated": "~1.9.0","react-native-restart": "0.0.17","react-native-safe-area-context": "^3.0.7","react-native-screens": "~2.9.0","react-native-snap-carousel": "^4.0.0-beta.5","react-native-svg": "12.1.0","react-native-tab-view": "^2.15.1","react-native-web": "~0.11.7","react-navigation": "^4.4.0","react-navigation-stack": "^2.8.2","react-redux": "^7.2.1","redux": "^4.0.5","redux-thunk": "^2.3.0","yargs-parser": "^18.1.3"  },"devDependencies": {"@babel/core": "^7.8.6","babel-preset-expo": "^8.2.3"  },"private": true}

Lesson learned: if you want to run an app on both ios and android, always monitor on both simultaneously before your app is too big to know where the issue is coming from....

Help appreciated


react-native : can't push to git because of hprof file

$
0
0

I would like to push my project into the github, however i just notice there is a file called java_pid14920.hprof inside the android folder and cause around 300MB

remote: error: File android/java_pid14920.hprof is 301.75 MB; this exceeds GitHub's file size limit of 100.00 MB

I wonder it is safe to delete this file ?

CocoaPods could not find compatible versions for pod "FBSDKCoreKit"

$
0
0

I am having trouble using this library, I followed the instructions with the facebook guide that appears on the readMe and did all the steps.

Before this, I used the react-native-fbsdk library which is now deprecated due to facebook releasing a newer version (0.9) of the SDK. In the instructions here says that you can add the pod that you need in the podfile of ios but when I add them and then pod install I get this error:

[!] CocoaPods could not find compatible versions for pod "FBSDKCoreKit":  In snapshot (Podfile.lock):    FBSDKCoreKit (= 9.0.1, ~> 9.0.1)  In Podfile:    FacebookShare was resolved to 0.1.1, which depends on      FBSDKCoreKit (~> 4.14)react-native-fbsdk-next (from `../node_modules/react-native-fbsdk-next`) was resolved to 4.0.0, which depends on  react-native-fbsdk-next/Core (= 4.0.0) was resolved to 4.0.0, which depends on    FBSDKCoreKit (~> 9.0.1)You have either: * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`. * changed the constraints of dependency `FBSDKCoreKit` inside your development pod `react-native-fbsdk-next`.You should run `pod update FBSDKCoreKit` to apply changes you've made.

Also, with this library you need to modify the appDelegate.m here but when I add that code it says I am missing an import, I know the import missing is FBSDKCoreKit or at least I think it is because the previous SDK used that one. To fix that you need to add the pod but when I add it the error above shows up.I don't know if I need the other library because of that dependency. please help!

Why GET-request in react-native doesn't work?

$
0
0

Here is my request code

backend() {    GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;    let xhr = new XMLHttpRequest();    xhr.open("GET", `https://randomday.ru/newValue/?value=${this.state.text}`, true);    xhr.send();    xhr.onload = function() {      if (xhr.status !== 200) {        console.log(`${xhr.status}: ${xhr.statusText}`);      } else {        let json = JSON.parse(xhr.response);        this.setState({ text: json.msg });      }    }.bind(this);    xhr.onerror = function(e) {      console.log(e.target.status);    };  }

It starts on push the button

<Pressable onPress={() => {           this.backend()}}

This works fine when i run the project with debugger in chrome, but normally the request returns "0 error".If anyrhing, i am accessing my server in django.

My AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"  package="com.myreact"><uses-permission android:name="android.permission.INTERNET" /><application      android:name=".MainApplication"      android:label="@string/app_name"      android:icon="@mipmap/ic_launcher"      android:roundIcon="@mipmap/ic_launcher_round"      android:allowBackup="false"      android:usesCleartextTraffic="true"      android:theme="@style/AppTheme"><activity        android:name=".MainActivity"        android:label="@string/app_name"        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"        android:launchMode="singleTask"        android:windowSoftInputMode="adjustResize"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>

Whats wrong?

React Native: Could not find support-vector-drawable.aar [duplicate]

$
0
0

I run react-native 0.57.1 app, then I got the following lines.

FAILURE: Build failed with an exception.* What went wrong:Could not resolve all files for configuration ':app:debugCompileClasspath'./> Could not find support-vector-drawable.aar (com.android.support:support-vector-drawable:27.1.1).  Searched in the following locations:      https://jcenter.bintray.com/com/android/support/support-vector-drawable/27.1.1/support-vector-drawable-27.1.1.aar/> Could not find livedata-core.aar (android.arch.lifecycle:livedata-core:1.1.0).  Searched in the following locations:      https://jcenter.bintray.com/android/arch/lifecycle/livedata-core/1.1.0/livedata-core-1.1.0.aar/> Could not find viewmodel.aar (android.arch.lifecycle:viewmodel:1.1.0).  Searched in the following locations:      https://jcenter.bintray.com/android/arch/lifecycle/viewmodel/1.1.0/viewmodel-1.1.0.aar/> Could not find runtime.aar (android.arch.core:runtime:1.1.0).  Searched in the following locations:      https://jcenter.bintray.com/android/arch/core/runtime/1.1.0/runtime-1.1.0.aar

React Native Crashed:Thread : SIGSEGV libjsc.so

$
0
0

We are getting following crash on various random places in android devices. Although we have changed ndk abifilters to "armeabi-v7a", "arm64-v8a"

  Crashed: Thread :  SIGSEGV  0x0000000000000010  #00 pc 0x723d46f748 libjsc.so   #01 pc 0x723d4bbfe8 libjsc.so   #02 pc 0x7339d68b6c libc.so 

Current configuration

RN version 0.63.4

 defaultConfig {    ..    ndk { abiFilters  "armeabi-v7a", "arm64-v8a" }}splits {    abi {        reset()        enable enableSeparateBuildPerCPUArchitecture        universalApk false  // If true, also generate a universal APK        include "armeabi-v7a","x86", "arm64-v8a", "x86_64"    }} project.ext.react = [    entryFile   : "index.js",    enableHermes: false,  // clean and rebuild if changing ]

enter image description here

enter image description here

Disable back button but when tap twice exit app in react native

$
0
0

I am trying to create a small react native app and in that app, I have created some screens. On a particular screen, I want to disable the system back button and I did that but I want to create a logic on that same screen that if the user taps twice then app will be closed.

My screen

import React, {Component, useEffect} from 'react';import { StyleSheet, Text, View, Button, BackHandler, Alert } from 'react-native';export default function HomeScreen({ navigation }) {    useEffect(() => {        BackHandler.addEventListener('hardwareBackPress', () => true)        return () =>            BackHandler.removeEventListener('hardwareBackPress', () => true)    }, [])    return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}><Text>Home Screen</Text><Button            title="Go to Other Screen"            onPress={() => navigation.navigate('Employees')}            /></View>    );}

But there is one more problem as well, This code is disabling back button on every screen.

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

$
0
0

Performing ./gradlew assembleRelease and hit the issue of this. Below shows the entire error log...

> Task :app:mergeDexRelease FAILEDjava.nio.file.NoSuchFileException: /Users/path/Desktop/project/android/app/build/intermediates/external_file_lib_dex_archives/release/out        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)        at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:412)        at java.base/java.nio.file.Files.newDirectoryStream(Files.java:472)        at java.base/java.nio.file.Files.list(Files.java:3699)        at com.android.build.gradle.internal.tasks.DexMergingParams.getAllDexFiles(DexMergingTask.kt:502)        at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:423)        at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)        at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:57)        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:198)        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)        at java.base/java.lang.Thread.run(Thread.java:834)w: Detected multiple Kotlin daemon sessions at build/kotlin/sessionsFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:mergeDexRelease'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> java.nio.file.NoSuchFileException: /Users/path/Desktop/project/android/app/build/intermediates/external_file_lib_dex_archives/release/out

Some story

During the debugging of this "multiple Koltin" issue, I found out that my NDK wasn't install. Hence I went to SDK Manager and install the NDK (Side by side). Then issue of toolchain occurred, shown as below.

No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

Fixed was done by downloading older NDK version, android-ndk-r19c and pointed the NDK path in my local.properties.

Local.properties

sdk.dir=/Users/path/Library/Android/sdkndk.dir=/Users/path/Library/Android/android-ndk-r19c

TLDR

What I've tried

  1. ./gradlew clean && ./gradlew assembleRelease
  2. Appending the following code + Step 1
# FILE 1: Gradle.propertiesorg.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8# FILE 2: app/build.gradle ( under android{} )dexOptions {        incremental true        javaMaxHeapSize "4g"}

My project env

react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2

My Project Structureenter image description hereenter image description here

Any idea what causes this issue and how to fix this? 🆘


Build Failing for React Native iOS, "Multiple commands produce" Error

$
0
0

We were working on a react native project. One of my team members added some native modules on Linux and linked android. By then I am trying to link things in iOS but the build is always failing with this kind of error trace. The Android project is building normally.

I deleted xyz.xcworkspace and Podfile.lock then tried pod install.
Also, I tried to delete my node_modules and then yarn install followed by yarn link.

react-native-cli: 2.0.1  react-native: 0.61.4  yarn 1.19.1Pod 1.8.4XCode Version 11.2.1 (11B500)macOS Catalina 10.15.1 (19B88)

xyz warning

duplicate output file '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/AntDesign.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/faisal/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Intermediates.noindex/xyz.build/Debug-iphonesimulator/xyz.build/Script-47F818C57EEC47EA3303EA1B.sh

xyz workspace errors

Multiple commands produce '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf':1) Target 'xyz' (project 'xyz') has copy command from '/Users/user/Desktop/xyz/native/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf'2) That command depends on command in Target 'xyz' (project 'xyz'): script phase “[CP] Copy Pods Resources”

There are multiple errors and warnings like this but have same format with different file names.

Enable all notification settings by default in my android app

$
0
0

Is there any way I can enable all notification settings by default when my app gets installed ?

Users are receiving notifications but sound is disabled by default and we need to manually enable it on the device. Not all users can do this manually. It would be great to know if there is any way we can check all these things when our app gets installed like WhatsApp or Telegram (they have everything checked by default)

enter image description here

Cant launch android app on android studio (react native)

$
0
0

Im triying to launch my android application on android studio (realised by react native)But the app doesnt show, and its giving me this error :

Configure project :react-native-navigationWarning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

I've changed the build.gradle (in android>app) but its doesnt match with the default configuration of the project, here is two versions of the applicationVariants.all (in android{...})which i've used (the building stopped everytime) :

    applicationVariants.all { variant ->      variant.outputs.each { output ->        def outputFile = output.outputFile        if (outputFile != null && outputFile.name.endsWith('.apk')) {            def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")            output.outputFile = new File(outputFile.parent, fileName)        }      }   }

the second :

applicationVariants.all { variant ->    variant.outputs.each { output ->    def outputFile = output.outputFile    if (outputFile != null && outputFile.name.endsWith('.apk')) {        def manifestParser = new com.android.builder.core.DefaultManifestParser()        def fileName = outputFile.name.replace(".apk", "-DEBUG-" +        manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile) +".apk")        output.outputFile = new File(outputFile.parent, fileName)    } }}

I've added this commande too

buildFeatures {viewBinding true}

But without result :/Hope someone could help me

How do I get metadata from a song file in react native for android?

$
0
0

I'm only interested in having it work for Android so a solution that doesn't work for iOS is fine.

By metadata I mean genre, album art, artist name, album name, etc.

I've tried using react-native-music-metadata and it seems like it would do what I want but it appears that it is too old to use since I want it to work for the newest Android and it says that it's incompatible with Gradle 7.0. If anyone can provide assistance with making this old API work with new phones, I'd be more than happy to use it.

Is there anything that will retrieve the metadata for me on React Native? If not, can you provide help with writing something that will do the same thing?

numberOfLines TextInput property not working

$
0
0

I have created an application in react-native and I have an option to chat in messages option. when I click inside TextInput and type two lines, the upper line gets hidden. To fix this I saw in the docs numberOfLines property but it did not work.

Here is my code:

<TextInput                ref='textInput'                multiline={true}                numberOfLines: {5}                onChangeText={this.onChangeText}                style={[styles.textInput, {height: context.props.textInputHeight}]}                placeholder={context.props.placeholder}                placeholderTextColor="#5A5A5A"                value={context.state.text}/>

I tried it in getDefaultProps function too:

getDefaultProps() {    return {      placeholder: 'Type a message...',      navHeight: 70,      textInputHeight: 44,      numberOfLines:5,      maxHeight: Screen.height,    };  },

But did not worked.

I'm trying to create a native module for react, but I found an error in build.gradle

$
0
0

I'm trying to create a native module to use in my react projects, its function will be to handle push notifications from firebase, however I'm not getting success, I followed the steps to implement firebase in an android application, however the module model that react's website advises to download it has one of the build.gradle missing, so I put all the implementations in the root build.gradle, this one is the build.gradle:

buildscript {    if (project == rootProject) {        repositories {            google()            jcenter()        }        dependencies {            classpath 'com.android.tools.build:gradle:3.5.3'            classpath 'com.google.gms:google-services:4.3.5'        }    }}apply plugin: 'com.android.library'def safeExtGet(prop, fallback) {    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback}android {    compileSdkVersion safeExtGet('FirebasePushAdvanced_compileSdkVersion', 29)    buildToolsVersion safeExtGet('FirebasePushAdvanced_buildToolsVersion', '29.0.2')    defaultConfig {        minSdkVersion safeExtGet('FirebasePushAdvanced_minSdkVersion', 16)        targetSdkVersion safeExtGet('FirebasePushAdvanced_targetSdkVersion', 29)        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false        }    }    lintOptions {        disable 'GradleCompatible'    }    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }}repositories {    mavenLocal()    maven {        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm        url("$rootDir/../node_modules/react-native/android")    }    google()    jcenter()}dependencies {    //noinspection GradleDynamicVersion    implementation "com.facebook.react:react-native:+"  // From node_modules    implementation platform('com.google.firebase:firebase-bom:26.8.0')    implementation 'com.google.firebase:firebase-messaging'    implementation 'com.google.firebase:firebase-analytics'}apply plugin: 'com.google.gms.google-services'

however when I start my react project it presents the following error:

FAILURE: Build failed with an exception.* Where:Build file 'C:\Users\lucas\Documents\GitHub\Teste\node_modules\react-native-firebase-push-advanced\android\build.gradle' line: 64* What went wrong:A problem occurred evaluating project ':react-native-firebase-push-advanced'.> Plugin with id 'com.google.gms.google-services' not found.

I've tried other third-party tutorials, but they all have a problem, if someone has a tip on where to start to create my native modules I will thank you, I'm new to this subject and the modules you have available do not meet my problem, thanks.

Edit: Repo of my module: https://github.com/lucassouza16/react-native-firebase-push-advanced

"react-native start" works, but crashes while "react-native run-android" is ongoing, even on a fresh project (bare workflow)

$
0
0

Running an app (created by "expo init appName" in Bare Workflow) on Android requires to first react-native start and then react-native run-android. What happens is -

  1. In 1st terminal, I run react-native start (tried from VS Code terminal, normal terminal, each of these as admin too). It works fine.

  2. In 2nd terminal, I run react-native run-android and the server crashes (in 1st terminal) and the 2nd terminal can either show error or show success.

In case of success, it's no use cause the server is not working so shows that error.

Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release.

In case of failure the error is (in the 2nd terminal, the one running react-native run-android)

> Task :app:createDebugExpoConfig FAILEDDeprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings30 actionable tasks: 2 executed, 28 up-to-dateinternal/fs/utils.js:307    throw err;    ^Error: ENOENT: no such file or directory, open 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\android\app\build\generated\assets\expo-constants\debug\app.config'    at Object.openSync (fs.js:476:3)    at Object.writeFileSync (fs.js:1467:35)    at Object.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\expo-constants\scripts\getAppConfig.js:20:4)      at Module._compile (internal/modules/cjs/loader.js:1063:30)       at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)    at Module.load (internal/modules/cjs/loader.js:928:32)            at Function.Module._load (internal/modules/cjs/loader.js:769:14)    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)    at internal/main/run_main_module.js:17:47 {  errno: -4058,  syscall: 'open',  code: 'ENOENT',  path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\android\\app\\build\\generated\\assets\\expo-constants\\debug\\app.config'}FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:createDebugExpoConfig'.> Process 'command 'cmd'' finished with non-zero exit value 1     * 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.orgBUILD FAILED in 42serror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081internal/fs/utils.js:307

and in the 1st terminal (react-native run)

events.js:292      throw er; // Unhandled 'error' event      ^Error: EPERM: operation not permitted, lstat 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\android\app\build\generated\assets\expo-constants'Emitted 'error' event on NodeWatcher instance at:    at NodeWatcher.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\sane\src\node_watcher.js:291:16)    at FSReqCallback.oncomplete (fs.js:183:21) {  errno: -4048,  code: 'EPERM',  syscall: 'lstat',  path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\android\\app\\build\\generated\\assets\\expo-constants'

the part showing module-name "expo-constants" is NOT always the same. It varies at times, but the general structure of the error is this. for example

events.js:292      throw er; // Unhandled 'error' event      ^Error: EPERM: operation not permitted, lstat 'D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\expo-error-recovery\android\build\kotlin\compileDebugKotlin\caches-jvm\jvm'Emitted 'error' event on NodeWatcher instance at:    at NodeWatcher.<anonymous> (D:\bareWorkflowRN\tester1PaymentsNPlacePicker\node_modules\sane\src\node_watcher.js:291:16)    at FSReqCallback.oncomplete (fs.js:183:21) {  errno: -4048,  code: 'EPERM',  syscall: 'lstat',  path: 'D:\\bareWorkflowRN\\tester1PaymentsNPlacePicker\\node_modules\\expo-error-recovery\\android\\build\\kotlin\\compileDebugKotlin\\caches-jvm\\jvm'}

I've tried (scouring the net, especially SO posts) -

a - delete node_modules and npm install

b - cd android and gradlew clean . No affect. I've tried this before react-native run and also in between the two mentioned commands.

I've tried these steps in various permutations for the last 2-3 days, but this is not solving.

I even thought that this might be due to the new expo version launch on 15th April, and maybe that's causing some versioning issues, so I tried with fresh projects made with expo init appName. No changes made to this fresh app, just tries to run it on the emulator. It works fine with expo start but if I try react-native start and react-native run-android, the same issues repeat.

One might note at this point, that the issue can be called cyclic in nature

Also, does it make sense to -

  • start the server react-native start
  • run react-native run-android, let the server crash and let the app install with error - "Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release."
  • then try react-native start again.

I think (don't know for sure) it doesn't make sense to start the server later, but out of my many efforts , this worked twice randomly. Could NOT be reproduced.

My system Windows 10here's my package.json (it's the one generated with a fresh app and is untouched)

{"main": "index.js","scripts": {"android": "react-native run-android","ios": "react-native run-ios","web": "expo start --web","start": "react-native start","test": "jest"  },"dependencies": {"expo": "~41.0.0","expo-splash-screen": "~0.10.2","expo-status-bar": "~1.0.4","expo-updates": "~0.5.4","react": "16.13.1","react-dom": "16.13.1","react-native": "~0.63.4","react-native-gesture-handler": "~1.10.2","react-native-reanimated": "~2.1.0","react-native-screens": "~3.0.0","react-native-unimodules": "~0.13.3","react-native-web": "~0.13.12"  },"devDependencies": {"@babel/core": "^7.9.0","babel-jest": "~25.2.6","jest": "~25.2.6","react-test-renderer": "~16.13.1"  },"jest": {"preset": "react-native"  },"private": true}

Any assist highly appreciated. Let me know if more information is needed


Is it possible to hide, show and control the native Android navigation with React Native Router Flux?

$
0
0

I want to be able to hide and show the native Android navigation and also hide / disable the back button using React Native Router Flux v5, or React Native v 0.63.3 (without writing any native modules):

enter image description here

So far I can't see anyway to control this from React Native Router Flux just navigation that is added on top of it. For example the ScenehideNavBar prop does not hide the native navigation, it hides navigation that the package adds.

I have been using this in code in my Android MainActivity, but I want to be able to control the navigation on a scene by scene basis from React Native, whereas this code will apply to the whole app:

    View decorView = getWindow().getDecorView();        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |         View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |         View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |        View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN        View.SYSTEM_UI_FLAG_FULLSCREEN |         View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY        );

My router stack is very simple and consists of one level of Scenes inside a stack:

return (<StoreProvider store={store}><PaperProvider><Router><Stack key="root"><Scene                        key="Landing"                        component={Landing}                        title="Landing"                        hideNavBar                    /><Scene                        key="WakingFromKilled"                        component={WakingFromKilled}                        title="Connecting"                        hideNavBar                    /><Scene                        key="Dashboard"                        component={Dashboard}                        title="Dashboard"                        hideNavBar                    />

How can I achieve this?

getLastLocation() returns location only after three to four attempts

$
0
0

I am using getLastLocation() api in my React-Native app to get the user location. User is given a button which calls getLastLocation() api when tapped on it(I am doing this through bridge). I set a timeout of 30 seconds. If no location is returned with in 30 seconds then

"Unable to get the location"

message is shown to user.

Every time when user tapped on button it takes at least three to four attempts to get the location. Users Wifi is turned on, mobile network quality is good, mobile data is turned on and location services are also turned on.This happens every day.

Is there any setting to be turned on in mobile or am I missing anything here?

Using Google Maps Circle Class in Expo React native App

App crashing when using multiple 3d objects in react-native-gl-model-view

$
0
0

Hey, I want to use 2 '3d object models' from react-native-gl-model-view simultaneously on one screen. When I use a single 3d object it works fine but as soon as I use two or more than two, every 3d object model starts flickering, and after a couple of seconds app crashes.

Here is how it works with multiple 3d objects

enter image description here

Here is the code:

import React, {Component} from 'react';import {StyleSheet, View, Animated} from 'react-native';import ModelView from 'react-native-gl-model-view';const AnimatedModelView = Animated.createAnimatedComponent(ModelView);export default class Multiple extends Component {  constructor() {    super();    this.state = {      rotateZ: new Animated.Value(0),    };  }  componentDidMount() {    this.animate(0);  }  animate(iteration) {    Animated.timing(this.state.rotateZ, {      toValue: ++iteration * 360,      useNativeDriver: true,      duration: 5000,    }).start(this.animate.bind(this, iteration++));  }  renderModel() {    return (<AnimatedModelView        model={{          uri: 'demon.obj',        }}        texture={{          uri: 'demon.png',        }}        tint={{r: 1.0, g: 1.0, b: 1.0, a: 1.0}}        animate        scale={0.01}        translateZ={-2.5}        rotateX={270}        rotateZ={Animated.add(this.state.rotateZ, Math.random() * 360)}        style={styles.model}      />    );  }  render() {    return (<View style={styles.container}><View style={styles.row}>          {this.renderModel()}          {this.renderModel()}</View></View>    );  }}const styles = StyleSheet.create({  container: {    flex: 1,  },  row: {    flex: 1,    flexDirection: 'row',  },  model: {    flex: 1,    backgroundColor: 'transparent',  },});

To load a model on Android, you need to place the model in the android/app/src/main/assets folder. Create a new folder if it doesn't exist yet.

assets/models which were used in the above code.

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation

$
0
0
FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':react-native-linear-gradient:compileDebugJavaWithJavac'.> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

When I upgraded to Mac os Big sur and run,

npx react-native run-android

I got this error (Android). I have tried a lot of solutions from Stack Overflow, but none of them worked.

I have created a fresh project and it's working. Also some of the old projects are also working perfectly.

*react-native Version: "0.63.3",*

Please help me to find a solution?

Viewing all 29459 articles
Browse latest View live


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