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

Android Facebook SDK lowers app performance in react native

$
0
0

I am using Facebook SDK for my android app. I am facing scroll lags and performance issues all over the app. Removing the sdk removes all the issues. But i intend to use the sdk for analytics purpose. Is there anything that has to be added with addition to sdk. Any insight is helpful.


How to add in app purchase to react native app?

$
0
0

So paid pages in my app, when a user click to open any of these pages i want to run a function to check if the product is purchased and if it's not then buy the product, I have found two packages which are react-native-iap and expo-in-app-purchase but did not find clear instructions on how to achieve the process i need..

const paidPage = async (productId , navTo) => { // PASS THE PRODUCT ID AND A FUNCTION THAT NAVIGATE TO THE PAGE // HERE I WANT TO CHECK IF THE PRODUCT IS PURCHASED, IF YES THEN NAVIGATE TO THE PAGE// IF NO THEN PURCHASE THE PRODUCT }

Unhandled error in debug adapter: SyntaxError: Unexpected token L in JSON at position 0

$
0
0

Error:

******** Unhandled error in debug adapter: SyntaxError: Unexpected token L in JSON at position 0        at JSON.parse (<anonymous>)    at Pipe.channel.onread (internal/child_process.js:471:28)

Hello Guys,

I had found a lot of other issues/questions like this here and any where else, but no of them includes "Unhandled error in debug adapter". I had tried a lot of workflows, but nothing worked.

Short Introduction:

OS: Windows 64x

IDE: VS Code (version: 1.25.1 / launch.json see below)

vscode-Plugin: React Native Tools (version: 0.6.12)

Language/Framework: React-Native

(React-version: 16.4.1 /RN-version 0.55.4 / cli-version: 2.0.1)

Project: Android App (iOS followed later)

Output of React-Native: Run androidInstalling APK 'app-debug.apk' was successful.

Output of React-Native: Starting custom debugger by executing: echo A debugger is not needed:"[project-location]" "[project-location].vscode"

Starting App with react-native run-android via terminal still working.

Try following troubleshooting steps:

  • comment out all JSON.parse() calls
  • check all fetch based functions
  • check older repository revisions
  • repair vscode
  • reinstall vscode
  • update RN to 0.56.0
  • change mobile device

Existing project is to large to show it here and dosn't exist in a public repo.

launch.json - I'm using "Debug Android"

{    "version": "0.2.0","configurations": [                {"name": "Debug Android",    "program": "${workspaceRoot}/.vscode/launchReactNative.js",    "type": "reactnative","request": "launch",    "platform": "android",    "sourceMaps": true,    "outDir": "${workspaceRoot}/.vscode/.react",        },        {"name": "Debug iOS","program": "${workspaceRoot}/.vscode/launchReactNative.js","type": "reactnative","request": "launch","platform": "ios","sourceMaps": true,"outDir": "${workspaceRoot}/.vscode/.react"        },        {"name": "Attach to packager","program": "${workspaceRoot}/.vscode/launchReactNative.js","type": "reactnative","request": "attach","sourceMaps": true,"outDir": "${workspaceRoot}/.vscode/.react"        },        {"name": "Debug in Exponent","program": "${workspaceRoot}/.vscode/launchReactNative.js","type": "reactnative","request": "launch","platform": "exponent","sourceMaps": true,"outDir": "${workspaceRoot}/.vscode/.react"        }    ]}

I don't know where the problem is located:

  • project
  • vscode
  • node
  • ...

Logcat prints only [INFO] no Warnings and no Errors.

Want to debug project with debug terminal of vscode, because debugging with chrome doesn't work with breakpoints.

I'm very new at working with vscode and RN, please explain possible solutions a little bit more detailed.

Thanks in advance.

Chris

Cannot build React-native Marketing Cloud

$
0
0

Having issues when building react-native app using ./gradlew assembleRelease

I've installed marketing cloud package

yarn add react-native-marketingcloudsdk

Added maven repo

maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }

Here's my MainApplication.java

package org.reactnative.example;import android.app.Application;import android.graphics.drawable.Drawable;import android.content.Context;import com.facebook.react.PackageList;import com.facebook.react.ReactApplication;import com.facebook.react.ReactInstanceManager;import com.facebook.react.ReactNativeHost;import com.facebook.react.ReactPackage;import com.facebook.soloader.SoLoader;import com.salesforce.marketingcloud.MarketingCloudConfig;import com.salesforce.marketingcloud.MarketingCloudSdk;import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;import java.lang.reflect.InvocationTargetException;import java.util.List;import android.util.Log;import androidx.multidex.MultiDexApplication;public class MainApplication extends MultiDexApplication implements ReactApplication {  private final ReactNativeHost mReactNativeHost =      new ReactNativeHost(this) {        @Override        public boolean getUseDeveloperSupport() {          return BuildConfig.DEBUG;        }        @Override        protected List<ReactPackage> getPackages() {          @SuppressWarnings("UnnecessaryLocalVariable")          List<ReactPackage> packages = new PackageList(this).getPackages();          // Packages that cannot be autolinked yet can be added manually here, for example:          // packages.add(new MyReactNativePackage());          return packages;        }        @Override        protected String getJSMainModuleName() {          return "index";        }      };  @Override  public ReactNativeHost getReactNativeHost() {    return mReactNativeHost;  }  @Override  public void onCreate() {    super.onCreate();    MarketingCloudSdk.init(this,      MarketingCloudConfig.builder()        .setApplicationId("SECRET")        .setAccessToken("SECRET")        .setSenderId("SECRET")        .setMarketingCloudServerUrl("SECRET")        .setAnalyticsEnabled(true)        .build(this),      initializationStatus -> Log.e("INIT", initializationStatus.toString()));    SoLoader.init(this, /* native exopackage */ false);    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());  }}

As per docs, that's enough for working with that package

But getting this error

FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':react-native-marketingcloudsdk:verifyReleaseResources'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> Android resource linking failed     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:161:5-169:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:194:5-204:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:213:5-221:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:238:5-241:13: AAPT: error: style attribute 'attr/layout_constraintDimensionRatio (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintDimensionRatio)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:250:5-260:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:272:5-280:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:295:5-298:13: AAPT: error: style attribute 'attr/layout_constraintDimensionRatio (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintDimensionRatio)' not found.     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:315:5-325:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.* 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.orgDeprecated 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.2/userguide/command_line_interface.html#sec:command_line_warningsBUILD FAILED in 2m 24s576 actionable tasks: 523 executed, 53 up-to-date

Not sure what's the problem

Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created

$
0
0

enter image description here

React Native app run fine without proguard enable on Android.When i enable proguard in android it show me this error and app crash.

How to get a versionName in react-native app on Android?

$
0
0

I've made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get versionName in code?

Socket.io and React native problems when I enter in the app

$
0
0

I have a problem when I start my aplication is continuously sending socket.on('connection'), this is my code in (client-side) App.js

import React, {useState, useEffect} from 'react';import axios from 'axios';import {View, StyleSheet, ActivityIndicator, ToastAndroid} from 'react-native';import {GoogleSignin} from '@react-native-community/google-signin';import auth from '@react-native-firebase/auth';import AsyncStorage from '@react-native-community/async-storage'import io from 'socket.io-client'export default function App() {  //Funciona como el constructor de states  const socket= io('https://evening-mountain-83408.herokuapp.com/');  useEffect(() => {  }, []);.... (More code here)}

And this is my (server-side) index.js

const express = require('express');const mongoose =  require ('mongoose')const app = express();const port = process.env.PORT || 3001;app.use(router);/*MONGODB*/mongoose.Promise = global.Promisemongoose.connect(mongodbRoute, options, (err) => {    if (err) {        return console.log(`Error al conectar a la base de datos: ${err}`)    }    console.log(`Conexión con Mongo correcta.`)})server =  app.listen(port, () => {  console.log(`Servidor up en ${port}`);});  //Socket.ioconst socket = require('socket.io');io = socket(server);io.on("connection", (socket) => {  console.log("alguien ha abierto la aplicación");  socket.on("updateUsers", (data) => {    console.log(`este es el console log de updateNow`);    console.log(data)    socket.broadcast.emit("updateNow", data);  });});

and this is the console.log I have in the server (this is what I see in heroku logs)

React Native on Android: Cannot run program "node": error=2, No such file or directory

$
0
0

The iOS version works fine, but running Android Studio on my Mac I get the following Gradle Build error (paraphrased):

:ReactNative:Running ‘[node, -e, console.log(require(‘react-native/cli’).bin);]’ command failed.- Where:Script ‘/Users/…/Desktop/…/node_modules/@react-native-community/cli-platform-android/native_modules.gradle’ line: 154- What went wrong:A problem occurred evaluating script.> Cannot run program “node”: error=2, No such file or directoryCaused by: java.io.IOException: Cannot run program “node”: error=2, No such file or directory

I've tried so many things:

I used to be able to still run yarn android in Terminal, but even that has stopped working.


Is it possible to build an Android SDK and iOS SDK using React Native?

$
0
0

In my company we are building Android SDKs and iOS SDKs. The reason why we are building SDKs is because we don't want to give away our code and methods to ours customers, we just want to hide how we connect to some services.

So i would like to know if is it possible to build an Android SDK and iOS SDK using React Native?, in the end you have to compile the code in order to create Android and iOS versions.

Thanks!

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.

Fastlane frameit screenshots on Android

$
0
0

Using fastlane with frameit and detox to run tests and take screenshots on ios and android devices for my react native application (https://dev.to/jeevankishore/e2e-detox-react-native-161o)

iOS works fine and is able to build, run the simulator, grab screenshots, and frame them with an iPhone 11.

Android builds and grabs the screenshots from the simulator but when I run fastlane frameit it is not framing my android screenshots. I tried a few simulators (pixel 3 xl and 3a) but keep getting:

Unsupported screen size [1440, 2960] for path './screenshots/SCREENSHOT.png' (pixel 3 xl dimensions) andUnsupported screen size [1080, 2220] for path './screenshots/SCREENSHOT.png (pixel 3a dimensions)

Confused because it says in the offsets list for frameit that the pixel 3 xl device is supported? I am finding it difficult to locate information on the supported devices. What I am doing wrong here.

https://fastlane.github.io/frameit-frames/latest/offsets.json

I have run fastlane frameit download_frames

For reference:

.detoxrc.json

"testRunner": "jest","runnerConfig": "e2e/config.json","configurations": {"ios": {"type": "ios.simulator","binaryPath": "ios/build/Build/Products/Release-iphonesimulator/APP.app","build": "xcodebuild -workspace ios/APP.xcworkspace -scheme APP -configuration Release  -sdk iphonesimulator -derivedDataPath ios/build","device": {"type": "iPhone 11"      }    },"android.emu.debug": {"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk","build": "cd android && ./gradlew app:assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..","type": "android.emulator","device": {"avdName": "Pixel_3_XL_API_29"      }    },"android.emu.release": {"binaryPath": "android/app/build/outputs/apk/release/app-release.apk","build": "cd android && ./gradlew app:assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..","type": "android.emulator","device": {"avdName": "Pixel_3_XL_API_29"      }    }  }}

Framefile.json

{"device_frame_version": "latest","default": {"background": "./background.jpg","keyword": {"font": "../../assets/fonts/Lato-Black.ttf","font_size": 124,"font_weight": 900,"color": "#FFF"    },"title": {"font": "../../assets/fonts/LatoBold.ttf","font_weight": 400,"font_size": 36,"color": "#D72429"    },"title_min_height": "52%","padding": 50,"interline_spacing": -2,"show_complete_frame": false,"stack_title": true  },"data": [    {"filter": "SCREENSHOT","title": {"text": "More text here"      },"keyword": {"text": "Text"      }    }  ]}

Android Play Store Performance Background Mode

$
0
0

I saw that on Android 9 version we coudn't get background geolocation less than 15 minutes just to not impact directly the RAM memory and performance, before I check that Android 11 did a update creating the 'Always allow' option with foregroundService Notification is possible use maybe 1/1 minute. my question is if there some stuff on Play store who can hinder to publish the app?

Thanks Humans ;)

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?

react-native run-android DeviceException Could not create ADB Bridge

$
0
0

I have created a React-Native project. When I run react-native run-ios, the build succeeds. But when I run react-native run-android I get this error:

* What went wrong:Execution failed for task ':app:installDebug'.> com.android.builder.testing.api.DeviceException: Could not create ADB Bridge. ADB location: /Applications/ADT/sdk/platform-tools/adb

Thanks in advance.

react native images not shown after building apk

$
0
0

I know this is a common know issue, but still no answwer as solved my problem.In my react native projet i have a folder 'pages' in which i store the js files for the pages to be shown. In this pages I whant to use images from a folder 'assets/images'.When I run it locally on a virtual device it works perfectly, but whenever I generate the apk and intall it on my device the images disappear.

enter image description here

Any help?


iOS policy on third party website rendering inside app

$
0
0

I have a react native app and I need to open third party websites inside my application. Will it be inappropriate to open inside a web component(in app browser) of the app? Or, shall I open it in a default safari browser?

Will iOS bar my app if I open third-party websites inside my app's web view? And what about google?

'react-native-mathjax' not rendering for single backslash

$
0
0

I am using 'react-native-mathjax' to render math equations. 'react-native-mathjax' not able to render for single backslash. When I add double backslash in place of single backslash and four backslashes in place of double backslash in the equation given below, 'react-native-mathjax' renders the equation, is there any solution?

    import React from 'react';    import { View, Text } from 'react-native';    import MathJax from 'react-native-mathjax';    function Test() {            return (<View><MathJax                        html={<p><span class="math-tex">\(\begin{bmatrix} 2 &1 \\[0.3em] 3&4\\[0.3em] \end{bmatrix}\)</span></p>} // not rendering this eqation                    /></View>     );    }    export default Test;

React Native, Failed to launch emulator. Reason: No emulators found as an output

$
0
0

I'm trying to run my react native app in emulator by using command react-native run-android but it's throwing that error

Deprecated 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.3/userguide/command_line_interface.html#sec:command_line_warningsBUILD SUCCESSFUL in 44sinfo Connecting to the development server...warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENTinfo Starting the app...The system cannot find the path specified.error Failed to start the app. Run CLI with --verbose flag for more details.Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity    at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)

I already setup my android studio and sdk manager, avd manager like it's shown in doc also I already set path but it's still showing that error, anyone know why? Can anyone help please?

How To Secure SD Card Media Assets (Video) in React Native Android..?

$
0
0

i am working on offline video streaming app in react native. i am storing all 30GB videos in sd card locally and play in react native app. Any good way to secure that video assts. i want to prevent that video stolen and copy anyone from that sd card.anyone have little bit idea about that please help me.

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?
Viewing all 29537 articles
Browse latest View live


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