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

react native edit file after build

$
0
0

Is there any way to edit a json file after the app was build? I heard that an apk file can be unzipped, but how about IOS? My goal is to make an app that can be changed by a non-programmer, after it was finished. Adding assets would be also good, but I don't think I would be possible.


Task 'assembleRelease' not found in root project 'android'

$
0
0

I'm using Reactnative 0.54.0 and react-native-cli 2.0.1 along side gradle 4.8.1

I have created a react-native project using create-react-native-app myProjectName

When I created the project, it doesn't include android and ios folders, so I added them manually.

I also installed gradle using choco and then created a wrapper for it using gradle wrapper --gradle-version 4.8.1 --distribution-type all

so I am developing react-native using microsoft vsCode and then see my application in action using Genymotion emulator, everything is fine

now, I want to generate the final Signed APK for play store, I'm using this guide provided by react-native

https://facebook.github.io/react-native/docs/signed-apk-android.html

When I want to run gradlew assembleRelease I get this error

C:\myApp\android>gradlew assembleReleaseFAILURE: Build failed with an exception.* What went wrong:Task 'assembleRelease' not found in root project 'android'.* Try:Run gradlew tasks to get a list of available tasks. 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 4s

what's wrong with assembleRelease? what should I do?

to add more info, I have to say that when I want to build this project in VSTS (TFS Online) I get this error

2018-07-17T16:20:14.9268702Z ##[error]Error: Not found wrapperScript: D:\a\1\s\gradlew

Any clue is appriciatedThanks

Update:as @philipp asked, this is the list of tasks that gradlew have listed and assembleRelease is not one one them!!!! what's the reason?

C:\myApp\Android>gradlew tasks> Task :tasks------------------------------------------------------------All tasks runnable from root project------------------------------------------------------------Build Setup tasks-----------------init - Initializes a new Gradle build.wrapper - Generates Gradle wrapper files.Help tasks----------buildEnvironment - Displays all buildscript dependencies declared in root project 'android'.components - Displays the components produced by root project 'android'. [incubating]dependencies - Displays all dependencies declared in root project 'android'.dependencyInsight - Displays the insight into a specific dependency in root project 'android'.dependentComponents - Displays the dependent components of components in root project 'android'. [incubating]help - Displays a help message.model - Displays the configuration model of root project 'android'. [incubating]projects - Displays the sub-projects of root project 'android'.properties - Displays the properties of root project 'android'.tasks - Displays the tasks runnable from root project 'android'.To see all tasks and more detail, run gradlew tasks --allTo see more detail about a task, run gradlew help --task <task>BUILD SUCCESSFUL in 1s1 actionable task: 1 executed

and this is myApp\android**build.gradle**

project.ext.react = [    bundleInStaging: true ]task wrapper(type: Wrapper) {    gradleVersion = '4.8.1'}android {    defaultConfig {        applicationId "com.sunkime.client"    }    signingConfigs {        staging {            keyAlias = "staging"            storeFile = file("my-release-key.keystore")            keyPassword = "qwert%$#@!"            storePassword = "qwert%$#@!"        }        release {            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {                storeFile file(MYAPP_RELEASE_STORE_FILE)                storePassword qwert%$#@!                keyAlias qwert%$#@!                keyPassword qwert%$#@!            }        }    }    buildTypes {        debug {            applicationIdSuffix ".debug"        }        staging {            applicationIdSuffix ".staging"            signingConfig signingConfigs.staging            minifyEnabled true            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"        }        release {            applicationIdSuffix ".release"            signingConfig signingConfigs.release            minifyEnabled true            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"        }    }}

I also used gradlew clean and no difference

Error Execution failed for task ':app:mergeReleaseResources' building APK

$
0
0

After trying to build APK once and fixing an error, I got an error executing ./gradlew assembleRelease again: Execution failed for task ':app:mergeReleaseResources' building APK

ReactNative & Expo: Trouble incrementing/decrementing to cycle through an Array

$
0
0

I am attempting to cycle through sound objects in an Array, using an index value that begins at 0 and increments/decrements depending on whether I press next or back.

This is for a music player for react-native using the Expo//expo-av library. I'll include all relevant code.

State I have in my Context file:

const initialState = {  startMusic: () => null,  stopMusic: () => null,  soundObject: null,  isPlaying: false,  currentIndex: 0,}useState()const [soundObject, setSoundObject] = useState(initialState.soundObject)const [isPlaying, setIsPlaying] = useState(initialState.isPlaying)const [currentIndex, setCurrentIndex] = useState(initialState.currentIndex)

Start Music function

const startMusic = async () => {    try {      const songToPlay = songs[currentIndex].song      const source = songs[currentIndex].path      await songToPlay.loadAsync(source)      await songToPlay.playAsync()      setSoundObject(songToPlay)      setIsPlaying(true)      return new Promise(resolve => {      // I made this promise when I was setting a loop to play through music.  May not need this anymore        songToPlay.setOnPlaybackStatusUpdate(playbackStatus => {          if (playbackStatus.didJustFinish) {            console.log("Song finished")            resolve()          }        })      })    } catch (error) {      console.log(`Error: ${error}`)      return    }  }

And finally, the handler functions that are supposed to cycle through songs:

const handlePreviousTrack = async () => {    if (soundObject) {      await soundObject.stopAsync()      await soundObject.unloadAsync()      // setSoundObject(null)      let newIndex = currentIndex      newIndex < songs.length - 1 ? newIndex-- : (newIndex = 0)      setCurrentIndex(newIndex)      startMusic()      console.log(currentIndex)    }  }  const handleNextTrack = async () => {    if (soundObject) {      await soundObject.stopAsync()      await soundObject.unloadAsync()      // setSoundObject(null)      let newIndex = currentIndex      newIndex < songs.length - 1 ? newIndex++ : (newIndex = 0)      setCurrentIndex(newIndex)      startMusic()      console.log(currentIndex)    }  }

Cycling through next/previous does not go in order. Sometimes it works, sometimes previous goes to the next song, sometimes pressing next just replays the first song.

Am I manipulating the state via currentIndex incorrectly?

How to set PDF height dynamically using 'react-native-html-to-pdf' package?

$
0
0

I am creating a PDF document in react-native. My aim is to create single page,no more pages and while my page's content gets bigger, my single page's height also must get bigger automatically.

options = {            width: 675,            height: ????,            html: `<div id="myDiv" style="width: 100%; min-height: 850px"> </div>`            }

In the above code, I set myDiv's min-height and when myDiv's height changes dynamically, I want to take this height value and set the option's height automatically. I tried javascript offsetHeight property but it does not work because HTML's inside is completely a string. I tried to use template literals, but i couldn't succeed.

Is there a way to handle this,using template literals or any other ways?

React native white blank screen when load website in a webview

$
0
0

Bug description: The site that I directed with Webview is opened in the ios simulator, Although not working in the andorid simulator.

To Reproduce:
react-native init AwesomeProjectcd AwesomeProjectreact-native run-android

&& my code

code

Expected behavior:. Work same as ios simulator

Screenshots/Videos:Screen Shot 2020-06-01 at 01 21 55Screen Shot 2020-06-01 at 01 22 16

Environment: - OS: macOS - OS version: 10.15.3 - react-native version: 0.62.2 - react-native-webview version: 10.2.3

How to implement deferred deeplink in branch for react native app?

$
0
0

I want my app to navigate to a particular screen after logon with the link clicked before install.

React-Native Execution failed for task ':app:packageDebug'

$
0
0

Whenever I try to run 'react-native run-android'

I got failure:

Execution failed for task ':app:packageDebug'

I tried checkout to previus commits.I tried removing android/app/build and re-buildI tried removing debug.keystore and initiated it again.

none of them solved the problem.

I successfully run my app before in android virtual device, and I've already uploaded my app to google play store, and it works.

I haven't seen this error before. My code worked totally fine before:

  • I removed some font files in android/src/main/assets/fonts. This maybe the reason.
  • I ran "react-native run-ios". This may be the reason.

Task :app:packageDebug 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.4.1/userguide/command_line_interface.html#sec:command_line_warnings117 actionable tasks: 5 executed, 112 up-to-date

FAILURE: Build failed with an exception.

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

    4 exceptions were raised by workers: java.io.UncheckedIOException: java.io.IOException: Execution of compression failed. java.io.UncheckedIOException: java.io.IOException: Execution of compression failed. java.io.UncheckedIOException: java.io.IOException: Execution of compression failed. java.io.UncheckedIOException: java.io.IOException: Execution of compression failed.

BUILD FAILED in 22s

at checkExecSyncError (child_process.js:629:11)at execFileSync (child_process.js:647:13)at runOnAllDevices (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)at buildAndRun (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)at then.result (/Users/leonkong/Desktop/dev/CoddingHippo/Native_Makkcha/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)

Build Success message. And running app on virtual device by android studio 2


Samsung J5/S5 fingerprint sensor unresponsive at App start

$
0
0

I am developing an App using React Native. I am using fingerprint sensor to authenticate the user to make some operations. Sensors is working fine on all iOS and Android devices except for Samsung J5 and S5. The problem is that when app starts, the sensor become unresponsive for a while (about 25/35 seconds) and then it works fine. If the app is restarted the problem reappears. It seems that sensor requires some warming up time when app starts. We tried al lot of different React Native plugins to use fingerprint, but with all plugins the problem still remains. I checked very carefully if there are some background operations, but the app seems idling and making no tasks. Worst scenario is when a remote Push Notification arrives, the App is closed and user tap the notification popup to authorize an operation, the App starts and the user cannot authorize it for about 25/35 seconds. The fingerprint prompt appears suddenly without problem and the "cancel" button is responsive. If the user tap "cancel" button of the fingerprint popup and reopens it, nothing changes, sensor still remains unresponsive. After 25/35 seconds from app start, all further fingerprint operations works fine and responsive. Has someone any idea about the cause? How we can to troubleshoot this problem?

how to run react-native run-android without internet?

$
0
0

I'm working on computer in internal network (without internet). I created react native app in another computer which is connected to the internet.I transfered the app to the first computer and i cannot run 'react-native run-android' because of it trying to download things that i've already transfered to this computer, such as gradle, jetifier, and more..

Generate "out of view" markers indicators on a map with React Native

$
0
0

For a project, I have to indicate, with colored arrows, in which direction are the markers that aren't shown in the visible region.

When the user scrolls, or zoom on the map, the arrows move accordingly to where the not visible markers are compared to the current center of the visible region.

Here is a picture that demonstrate what is needed :

enter image description here

I am using react-native-mapview and added regular views over the map to show the indicators.

I've started working on this by comparing the coordinates and calculating the point of intersection between lines (border lines and line made by the 2 coordinates) at each frame. It works fine on iOS but is pretty laggy on Android, especially chan there are a lot of markers involved.

What would be the best and optimized way to do this ?

Android-studio: Unable to locate adb

$
0
0

I read the answers "unable to locate adb" using Android Studio and Error:Unable to locate adb within SDK in Android Studio and it didn't solve my problem.

I use the 4.0 android-studio and Ubuntu 18.04

When I click on "launch this AVD in the emulator", I get an error message "Unable to locate adb".I did look in the Android/Sdk/platform-tools, I have an "adb" executable.

After the "unable to locate adb" error message, the AVD still launches. But, when I try to run my react native app on it, I get the 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

I'm pretty sure the react-native part is fine, but that route to the emulator is not the same as before.

It was working before. Yesterday, out of the blue, when I launched my android-studio, it "restarted" (showing me the install wizard, etc), and it seems it messed up its configuration.

After installation react-native-vector-icons white screen

$
0
0

Before installation the react-native-vector-icons, The project is work well.
But ..
When I install the react-native-vector-icons, I can only see the white screen .
It took me two days to solve this problem.
But it doesn't work. I add it like this:

npm install react-native-vector-icons --save
react-native link

Build success and no error or warnning,I compared with npm website,all of the file was the same,like android/app/build.gradle setting.gradle and so on, but it doesn't work in my android phone.
Thx for any help!I'm almost broke.

React Native android build failed. SDK location not found

$
0
0

I have error when i start running android

What went wrong:A problem occurred evaluating project ':app'.  > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

Release APK Not Updating With JavaScript Code

$
0
0

My Android APK is running off the JavaScript present when I generated the first signed APK. I've tried cleaning/rebuilding the project in Android Studio, I've tried ./gradlew clean in the android subfolder. Any ideas as to why the code isn't updating? I've seen this issue, without any success for myself.


Android emulator not running with my React Native App

$
0
0

Trying to run my React Native app in Android emulator but it keeps throwing error:
"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 haveset up your Android development environment:https://facebook.github.io/react-native/docs/getting-started.htmlerror spawnSync ./gradlew EACCES. Run CLI with --verbose flag for more details."

Tried react-native run-android, npm start, react-native start... nothing worked!!!

enter image description here

enter image description here

Am I missing out something here?? struggling with this since morning. Please help....

What make an image to be displayed only in IOS

$
0
0

As the title say

What make an image to be displayed only in IOS

in Android , it display a blank white image

the source fetched from a remote url

import { Image } from 'react-native';image = {uri : "correct_image_url"}<Image style={{width : 100 , zIndex : 999 , height : 100}} source={image} />

enter image description here

I use Expo , if this can help

How can I have nested horizontal ScrollViews in React Native?

$
0
0

I saw that React Native offers nested vertical scroll-views from React Native Nested ScrollView Can`t Scroll on Android Device

The problem is that it doesn't seem to work on nested Horizontal ScrollViews on Android. See this code for an example:

https://snack.expo.io/@harrytravelchime/broken-horizontal-scroll

import React from 'react';import _ from 'lodash';import { View, ScrollView, StyleSheet, Text, SafeAreaView } from 'react-native';export default class App extends React.PureComponent {  render() {    return (<SafeAreaView style={styles.container}><ScrollView          style={{ height: '100%', width: '100%' }}          horizontal          nestedScrollEnabled><View style={{ flexDirection: 'row' }}><ScrollView              style={{ width: 200, height: '100%' }}              horizontal              nestedScrollEnabled><View style={{ flexDirection: 'row' }}>                {_.times(200, n => (<View key={1000 + n} style={{ marginRight: 10 }}><Text>{1000 + n}</Text></View>                ))}</View></ScrollView>            {_.times(200, n => (<View key={n} style={{ marginRight: 10 }}><Text>{n}</Text></View>            ))}</View></ScrollView></SafeAreaView>    );  }}const styles = StyleSheet.create({  container: {    flex: 1,    flexDirection: 'column',    justifyContent: 'center',    alignItems: 'stretch',    paddingVertical: 50,  },});

On the other hand, the same code except with vertical scrolling totally works: https://snack.expo.io/@harrytravelchime/working-vertical-scroll

Is there a way to make nested horizontal scrolling work?

React native execute code before phone shuts down (app in foreground)

$
0
0

I am currently developing a React Native app. I need to execute some code before the phone shuts down (powered off/out of battery while my app is in foreground), is it possible? and how i do that? Thank you in advance

Expo Permissions returns status of 'undetermined' in Production

$
0
0

In my react native app which I ave published on the Google Play Store, I require Camera Roll permissions. This works during testing, but not in the published version of the app.

  getPermissionAsync = async () => {    const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);    if (status !== "granted") {      alert("Sorry, we need camera roll permissions to make this work!");    }    await this.setState({ permission: status === "granted" });  };  _pickMedia = async () => {    if (this.state.permission != true) {      await this.getPermissionAsync();    }    if (this.state.permission == true) {        // get image    }  };

In testing this works as expected, asking permission to access the camera roll every time the user tries to upload a picture till its given. However in production, the user is prompted once for permission to use the camera roll and whether or not they allow it, the alert box comes up and the user is unable to pick an image. If they try to add media again, they aren't prompted for permissions and it just alerts again.

As per the expo docs I have added READ_EXTERNAL_STORAGE to my permissions in app.json:

"android": {"permissions": ["READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"],    }

Could someone tell me why this doesn't work in production?

Viewing all 28463 articles
Browse latest View live


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