I'm trying to run my first React Native project for first time on my device (Android 4.2.2).
And I get:
unable to load script from assets index.android.bundle
Commands that I used:
cd (project directory)react-native startreact-native run-android
I'm trying to run my first React Native project for first time on my device (Android 4.2.2).
And I get:
unable to load script from assets index.android.bundle
Commands that I used:
cd (project directory)react-native startreact-native run-androidI have made sure that bundler and emulator are running.
If I use this commend
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
It might work but refresh won't happen when I press rr in emulator.
I have also tried reversal of abd adb reverse tcp:8081 tcp:8081.
Nothing works for me.
I want to notify users to update the app and when they click an update button, it opens TestFlight. How can I link to TestFlight?
https://beta.itunes.apple.com/v1/app/xxx does not work.
I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running /User/Pan/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync /User/Pan/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/User/Pan/Library/Android/sdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.785 secs
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
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck https://stackoverflow.com/a/38536290/4540216
OS: Windows 10 OS 64 bit CPU: Intel core i7-9700k @ 3.60GHz Memory: 550.87 MB / 16.00 GB
Issue related to both Android and IOS
Android: 9 iOS: 13.1.3 react-native-netinfo: 5.0.0 react-native: 0.61.4 expo: 36.0.0
In my expo project i need details like ssid , ipAddress of WiFi to which current phone is connected. i followed below procedure as follows :
first step i did npm install --save @react-native-community/netinfo
second step i imported NetInfo from “@react-native-community/netinfo”;
third step i wrote below code
NetInfo.fetch().then(state => {
console.log(“Connection type”, state.type);
console.log(“Isconnected?”, state.isConnected);
console.log("Details ", state.detail);
});
following is the output i can see on my terminal
Connection type wifi
Is connected? true
Detail? Object {
“ipAddress”: “192.168.0.171”,
“isConnectionExpensive”: false,
“ssid”: "DM",
“subnet”: “255.255.255.0”,
}
Is connected? true
Detail? Object {
“ipAddress”: “192.168.0.171”,
“isConnectionExpensive”: false,
“ssid”: null,
“subnet”: “255.255.255.0”,
}
So if you see in output Details i get all the detalis like ssid, subnet for Android but incase of iOS ssid is always null even after giving location permission. As i am newbie to react native i don’t understand where did i do mistake because of which i am not getting wiFi ssid and ipaddress. Please give me a solution for the above mentioned problem. I dont want to eject from Expo.
I have a TextInput in landscape mode with the disableFullscreenUI prop set to false. In this scenario the keyboardDidShow and keyboardDidHide callback is not being called on keyboard visibility change. It works perfectly fine in portrait mode and in landscape if disableFullscreenUI is set to true.
Keyboard.addListener('keyboardDidHide',this.keyboardWillHide);
Keyboard.addListener('keyboardDidShow',this.keyboardWillShow);
keyboardDidShow = (e) => { console.log("Keyboard is shown") }
keyboardDidHide = () => { console.log("Keyboard is hidden") }
React Native | react-native-google-signin
After i install react-native-google-sigin with
npm i react-native-google-signin
It suddenly crash ( force close ) right when the app start, I have already did all the steps that is told on the github documentation yet when i run my App it crash instantly, without giving any error in the log. ( neither android-log nor adb logcat *:S ReactNative:V ReactNativeJS:V does )
Here are my codes:
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
classpath 'com.android.tools.build:gradle:3.1.2' // <--- use this version or newer
classpath 'com.google.gms:google-services:4.1.0' // <--- use this version or newer
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
}
}
settings.gradle
rootProject.name = 'App'
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-google-signin', ':app'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':app'app/build.gradle
dependencies {
implementation project(':react-native-reanimated')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation(project(":react-native-google-signin"))
implementation "com.facebook.react:react-native:+" // From node_modules
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
apply plugin: 'com.google.gms.google-services' // <--- this should be the last line
Can someone help me with this error? because when i uninstall react-native-google-signin with
npm uninstall react-native-google-signin
it works just fine
I'm building a react-native app which expected to work a lot in the background.
There is a process that the user could go through when the app is either in background or foreground. I've modeled it as transitioning between screens.
The first screen transition happens at specific time using setInterval which checks a time-based condition. Then on this screen there are commands to transition to the next screen automatically.
The total process:
MainScreen -> Screen 1 -> Screen 2 -> MainScreen
In iOS, it works great when the app in the background and I had no issues. in android, the background process which was supposed to transition to Screen 1 stopped working when app was in the background.
using react-native-background-timer in android solved that.
But now, after the first transition, no navigation command works. Even if I open Screen 1 and then directly try to active goBack I see it keeps rendering Screen 1 when the app is in the background.
This question already has an answer here:
I Have a problem, to send text data (String) into Native Module Java in React Native.
If you have a tutorial or solution link, please share thanks.
I want to open 'Udemy for Business' app from my react native app.I tried udemyufb:// and it is working fine in iOS but not in Android.Any solution?
When i try to build a react-native project this error happens:
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat ap
p:installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment v
ariable or by setting the sdk.dir path in your project's local properties file a
t 'D:\COURSES\React Native - The Practical Guide\myFirstApp\android\local.proper
ties'.
* 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 4s
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 have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag
for more details.
I can't run the project on Genymotion because of this problem .
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.
I am trying to show a large list in react native - Expo. When i lock the screen while data loading via API. App State changed from "Active" to "Inactive". When i return to active state, no data has been loaded. The App processes are stopped. ListEmptyComponent renders the ActivityIndicator. It is loading indefinitely. It occurs only in android build.
I tried to recall the API by AppState.
const handleAppStateChange = nextAppState => {
console.log(nextAppState);
if (nextAppState === 'active') {
console.log(JSON.stringify(Store.apiCall));
// "Store.apiCall" has data about last API Call and its status.
if (Store.apiCall.status === codes.PENDING || Store.apiCall.status === codes.ERROR) {
api(Store.apiCall.payload);
}
}
setAppState(nextAppState);
};
Still it doesn't works..
When executing react-native run-android I get the following error:
> Task :app:checkDebugDuplicateClasses FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.android.gms.gcm.PendingCallback found in modules jetified-firebase-jobdispatcher-0.6.0-runtime.jar (com.firebase:firebase-jobdispatcher:0.6.0) and jetified-play-services-gcm-16.1.0-runtime.jar (com.google.android.gms:play-services-gcm:16.1.0)
Apparently there are two kinds of two packages that are in conflict. I've been days trying to compile my existing react-native project but I haven't made progress.
I did the update of my project from android to AndroidX through Android Studio through
Refactor -> Migrate to AndroidX
All the dependencies were overwritten by the new ones (with androidx, in theory).
I also already have the flags in my gradle.properties:
android.enableJetifier = true
android.useAndroidX = true
Also after this I run on console: npx jetify
Any idea why this is happening to me, below I leave my configuration files.
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 28 //SE COMENTO ESTO POR ERRORES EN EL SYNC DE ANDROID STUDIO. 2019-07-11
//targetSdkVersion = 29
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "15.0.1" // <--- use this version or newer
pdfViewer = "2.8.2" //https://www.npmjs.com/package/react-native-view-pdf
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "https://maven.google.com"
}
maven { url "https://www.jitpack.io" }
}
}
//task wrapper(type: Wrapper) {
wrapper{
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
android/app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '29.0.0'
defaultConfig {
applicationId "com.blablabla"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 15
versionName "0.31"
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
debug {
storeFile file('keystore/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
release{
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
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
}
}
}
//Se agregan estos packagingOptions porque no hace Build al haber instalado librerias de carga de fotos (react-native-crop-picker) 2019-12-10
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation project(':react-native-fast-image')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-device-info')
implementation project(':react-native-view-pdf')
implementation project(':amazon-cognito-identity-js')
implementation project(':@aws-amplify_pushnotification')
implementation project(':react-native-webview')
implementation project(':react-native-google-signin')
implementation project(':react-native-splash-screen')
implementation project(':react-native-keychain')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-vector-icons')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.facebook.react:react-native:+'
// From node_modules
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services' // <--- this should be the last line
I have a React Native app with firebase for backend,
And now I'm in the last part to release it, But I have a question, after releasing my app I will add some updates or something and I want to ensure every user updates, so should I implement a modal that appears after adding some updates to my app and publishing it to stores
So I just thought if I made a boolean item if I add updates just change it to True and in my code if that true modal appeared else hidden it!
So that's a nice way to go with it?
Or can firebase help me in this case to tells any new things I do "I don't send to them push notifications if u want to tell me that"
When I am trying to generate android apk by using ./gradlew installRelease, I get this error in console:
~/React-Native/mockingbird/android/app/build/intermediates/res/merged/release/drawable-mdpi-v4/src_resources_img_loading.gif: error: Duplicate file.
~/React-Native/mockingbird/android/app/build/intermediates/res/merged/release/drawable-mdpi/src_resources_img_loading.gif: Original is here. The version qualifier may be implied.
I tried Build->Clean Project via Android Studio and ran ./gradlew installRelease again; it didn't work either.
Also, I tried deleting the build folder, but it doesn't help either.
I was trying to start running my react native project. But I'm getting this error while running the react-native run-android command. I tried a bunch of solutions that I found online but neither of them worked.
info Starting JS server...
info Installing the app...
> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /home/dipanshuchaubey/Android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in /home/dipanshuchaubey/Android/Sdk/licenses
Warning: License for package Android SDK Platform 28 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/dipanshuchaubey/Android/Sdk
* 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 3s
error Failed to install the app. Please accept all necessary SDK licenses using SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/dipanshuchaubey/Android/Sdk
* 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 3s
at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:15)
at runOnAllDevices (/home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
at buildAndRun (/home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
at /home/dipanshuchaubey/Documents/practice/native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Command.handleAction (/home/dipanshuchaubey/Documents/practice/native/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:7)
How to fix this.
Thank you in Advance :)
I have been searching for a solution for a long time, but surprisingly, I think nobody has faced it yet. So I am posting it.
I have created a simple Drawer Navigator with React Navigation V3. I have added a Menu icon, and when I click it, the drawer appears as it should be. But, no hand gesture is working. Swiping from left to right don't do anything. Even when the drawer is open, tapping on empty space doesn't close the drawer.
Here is my code:
import {
createStackNavigator,
createSwitchNavigator,
createAppContainer,
createDrawerNavigator
} from 'react-navigation';
import Home from './screens/Home';
import LoginForm from './screens/LoginForm';
import Articles from './screens/Articles';
const AuthStack = createStackNavigator({
LoginScreen: LoginForm
});
const AppStack = createDrawerNavigator({
HomeScreen: Home,
ArticlesScreen: Articles
});
const RootNavigator = createSwitchNavigator(
{
Auth: AuthStack,
App: AppStack
},
{
initialRouteName: 'Auth'
}
);
export default createAppContainer(RootNavigator);
I thought like if I give width: 10, it will look the same in all devices since it occupied the same amount of area (because in 160dpi, 10dp = 10px, 320dpi 10dp = 20px but occupies same area in an inch)).I think my understanding is wrong. Share your thoughts on Responsive design and how to approach responsive font size as well. Thanks.