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

react native android: TypeError: Network request failed

$
0
0

I'm using fetch command, running on Android emulator. When I used it with port "127.0.0.1" I got this error all the time no matter what type of request I was doing.

Then I changed it to http://10.0.2.2, and GET requests generally work, but I'm trying to make a POST request and get this error:

TypeError: Network request failed

My code:

const url = 'http://10.0.2.2:143'            const payload = {                method,                headers: {                    Accept: 'application/json','Content-Type': 'application/json',                    ['x-access-token']: `Bearer ${token}`,                },                body,            }            const response = await fetch(url, payload)

On iOS everything's working fine so I don't think it's a problem with this code. What can I try to make it work on Android

The request doesn't even reach the server


React Native app keeps closing on android emulator

$
0
0

I'm trying to run a react native app on the android emulator (react-native run-android), however it keeps crashing with the error message "MYAPP has stopped". I'm trying to figure out where I can debug this further (error messages, logs, etc). I don't exactly see any error messages on the terminal nor on the emulator itself. So besides trying to resolve why the app won't deploy ... where does one look to further debug app deployment issues on an android emulator?

enter image description here

Side note: I upgraded from version 0.31.0 to 0.32.0 and ran the react-native upgrade command, which also required that some files be over-written (I chose the option to overwrite all files). Should I be worried that the latest changes from upgrade to 0.32.0 are not working or incomplete? Any steps I can take to verify that the latest changes are there?

Update: I created a new sample react native project just to see if there was something wrong with RN's latest version. It worked fine. Then took the sample code in index.android.js and overwrote it in my project's index.android.js and re-ran. Still getting the same issue with trying to deploy it to an Android emulator. Removed the node_modules directory, reran, still same issue. I'm now thinking this has something to do with the upgrade process... this is very frustrating.

Update v2: Thanks to @GabeSechan for the hint and direction, here's the stack trace that I found:

09-04 03:24:41.297  5008  5008 E AndroidRuntime: FATAL EXCEPTION: main09-04 03:24:41.297  5008  5008 E AndroidRuntime: Process: com.helpr, PID: 500809-04 03:24:41.297  5008  5008 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.helpr/com.helpr.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread.-wrap12(ActivityThread.java)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:154)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6077)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)09-04 03:24:41.297  5008  5008 E AndroidRuntime: Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.facebook.react.ReactApplication09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at com.facebook.react.ReactActivity.getUseDeveloperSupport(ReactActivity.java:89)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:96)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:6664)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)09-04 03:24:41.297  5008  5008 E AndroidRuntime:    ... 9 more

After a quick google search, it seems this is an existing issue when it comes to upgrading React Native. I'll post an answer, answering my own question.

React native rename error - app keeps stopping

$
0
0

I am using react-native-rename to rename my project. When I build my app I get the error, App keeps stopping.

Any ideas how I can solve this?

Logcat gives me an error:

2020-01-16 10:21:25.792 9881-9881/uk.nhs.dgft.tc E/WindowManager: android.view.WindowLeaked: Activity uk.nhs.dgft.tc.MainActivity has leaked window DecorView@f512995[] that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:485) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:346) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93) at android.app.Dialog.show(Dialog.java:330) at org.devio.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:36) at android.app.Activity.runOnUiThread(Activity.java:6184) at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:27) at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:49) at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:56) at uk.nhs.dgft.tc.MainActivity.onCreate(MainActivity.java:18) at android.app.Activity.performCreate(Activity.java:7009) at android.app.Activity.performCreate(Activity.java:7000) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

MainActivity:

package uk.nhs.dgft.tc;import com.facebook.react.ReactActivity;import org.devio.rn.splashscreen.SplashScreen;import android.os.Bundle;import com.facebook.react.ReactActivityDelegate;import com.facebook.react.ReactRootView;import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;public class MainActivity extends ReactActivity{    /**     * Returns the name of the main component registered from JavaScript.     * This is used to schedule rendering of the component.     */    protected void onCreate(Bundle savedInstanceState)    {        SplashScreen.show(this);  // here        super.onCreate(savedInstanceState);    }    @Override    protected String getMainComponentName()    {        return "tcapp";    }    @Override    protected ReactActivityDelegate createReactActivityDelegate()    {        return new ReactActivityDelegate(this, getMainComponentName())        {            @Override            protected ReactRootView createRootView()            {                return new RNGestureHandlerEnabledRootView(MainActivity.this);            }        };    }}

react native build release from .apk to .aab, how to send the app to the clients?

$
0
0

It's been so long since I develop a mobile app in react native, when I'm developing before, I usually generate a release apk and send it to my clients so that they can test it and have experienced it, but now when I build a release in react native, it returns a .aab instead of .apk, how can I send my application to the clients when I only get .aab format on my project?

Android app, app keeps stopping error after rename

$
0
0

I have recently renamed my react-native app using react native rename

My app works fine in my emulator, but when installed on device, I get the error 'app keeps stopping' as soon as I click the launch icon.

I've checked all the occurrances of my app name and it seems ok. How can I debug the error?

No such property: variantManager

$
0
0

I have an issue on the compilation on vs code and on android studio:

The build view:

FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':react-native-ble-plx'.> No such property: variantManager for class: com.android.build.gradle.LibraryPlugin

Thanks for your help :)

Android Gradle Pugin Version : 3.6.1Gradle Version 5.6.4

I need Box shadow property like this button in react native

$
0
0

enter image description hereI use this property but can not work

shadowColor: "#000",    shadowOffset: {        width: 0,        height: 2,    },    shadowOpacity: 0.25,    shadowRadius: 3.84,    elevation: 5,

React native gradle build fail : "node -e console.log(require('react-native/cli').bin);" : command fail

$
0
0

I try to run my React Native app in an android emulator on a fresh Ubuntu 18.04 installation.

In Android studio, gradle build failed with this error :

[org.gradle.api.Script] :ReactNative:Running '[node, -e, console.log(require('react-native/cli').bin);'] command failed.[org.gradle.internal.buildevents.BuildExceptionReporter] * Where:[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Script '/home/melvine/DevProjects/production/evener/mobile/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 179

However, when I run the following command in the project folder, it runs successfully.

$ node -e "console.log(require('react-native/cli').bin);"/home/melvine/DevProjects/production/evener/mobile/node_modules/react-native/node_modules/@react-native-community/cli/build/bin.js

What is wrong ?


How to debug the android app in emulator/device on react native 0.62.0?

$
0
0

I have updated my react native app to version 0.62.0 from 0.59.0 some time ago. I am able to debug the app on ios simulator and device but not able to get the in app developer menu on android by pressing the command+m key for emulator and device (on shaking the device). While updating I skipped the code for Flipper which is a new debugging tool that comes by default with RN 0.62.0.I am also not able to see the change in app when I run the app from Android Studio.

Is it not possible to use the shake gesture feature or debug the app without Flipper on Android ?

Create Native SDKs with React Native

$
0
0

I want to create client libraries for my backend for iOS and Android. They will be using native services like location services.

Instead of creating a separate SDK for each, I was wondering if I would use React Native to create the SDK, and then compile(eject) it to a native iOS pod or Android aar library. Is this possible to achieve with React Native? If yes, how can this be achieved?

React Native expo, apk build error: sdkVersion is missing from app.json

$
0
0

I am getting this error: "sdkVersion is missing from app.json" after doing exp build:android in my React Native expo app.Here is my app.json

    {"expo": {"name": "Parallel Desk","slug": "RN-ParallelDesk","platforms": ["ios", "android", "web"],"version": "1.1.0","orientation": "portrait","icon": "./assets/icon.png","splash": {"image": "./assets/splash.png","resizeMode": "contain","backgroundColor": "#ffffff"    },"updates": {"fallbackToCacheTimeout": 0    },"assetBundlePatterns": ["**/*"],"android": {"package": "com.paralleldesk.paralleldesk","versionCode": 1,"icon": "./assets/icon.png"    }  }}

error and code

Sending commands to Alexa Echo with own App

$
0
0

I'm trying to build a React-Native App which communicates with some smart devices.I've already implemented a script which allows me to easily send http-requests to the Phillips Hue and control the lightness and color. Same for Ikea Tradfri.

Now I was wondering if the same stuff is possible for Alexa Echo. So in the best case, I would be able to send every command, which the user actually says to alexa, in text-form within a http-request like:

request to alexa:...body:{"Set an alarm clock"}

But it would be enough to just send some commands with the requests and not actual user's input in text-form.

  • Is it in general possible to send commands to Alexa, similar with respect to Hue?
  • I might need to build an Alexa Skill right? Can I combine this with my React-Native App?
  • Are you aware of any good starting point / tutorials how to do this?

Thanks!

Thanks for helping!

React Native Android App crashes when receiving FCM notification

$
0
0

I have a react native app and I'm trying to implement push notification with the react-native-push-notification package and firebase cloud messaging. It turns out that when I get a notification, the app just stops working. The RemotePushController function seems to work, as soon as the App starts I get the console log with the token. I've tried several things but nothing works.

enter image description hereenter image description here

[enter image description here][enter image description here[][2][2]

enter image description here

React Native not showing, yet I am doing everything right

$
0
0
<ScrollView style={{ flex: 1 }}><Text style={{ marginTop: 50 }}> HELLOOx</Text><Image    style={{ width: 200, height: 200 }}    source={{      uri:"https://cdn.pixabay.com/photo/2016/10/02/22/17/red-t-shirt-1710578_1280.jpg",    }}  /><Image    source={{      uri:"https://cdn.pixabay.com/photo/2014/10/23/18/05/burger-500054_1280.jpg",    }}    style={{ width: 200, height: 200 }}  /></ScrollView>

The first image does not load, yet the second one does. Any guesses?enter image description here

React-native 0.61.2 with hermes disassembling index.android.bundle

$
0
0

I created a release build of my app with react-native 0.61.2 and enabled Hermes. In my Crashlytics I receive information about crashes along with stacktraces. Perviously I used to apply apktool to extract index.android.bundle from my apk, and it contained js code where I was able to find the issue by stacktrace.

But now using Hermes index.android.bundle seems to contain bytecode rather than js and I wasted a day trying to disassemble it. The last thing I tried was hbcdump tool mentioned in https://github.com/facebook/hermes/blob/master/doc/BuildingAndRunning.md, but all I get is "Error: fail to deserializing bytecode: Wrong bytecode version. Expected 73 but got 62"

What should I do to disassemble index.android.bundle created with Hermes? Any help is highly appreciated!


React Native - Why we use the tintColor property for Image component?

$
0
0

When i use tintColor property it fills the whole image to the color i specified to the tintColor property. Is i am using it wrong or its job is the same what i get? Can anyone tell for what purpose this property is used for <Image/> component and what is the proper use of this property? A little example will be more appreciated. Thanks !!!

Reference link

Google Places API + ReactNative

$
0
0

I'm trying to utilize Google Places API in Android app.I'm using React Native and the following package:https://github.com/FaridSafi/react-native-google-places-autocomplete

  1. API key in Google console created
  2. Restriction set to Android app (SHA1 fingerprint + package name)
  3. SHA1 fingerprint and package name values checked with:
    • aapt dump badging app-release.apk
    • unzip -p app-release.apk META-INF/CERT.RSA | keytool -printcert
  4. API key don't have any API usage restriction (can be used with any service)
  5. Places API enabled
  6. Maps JavaScript API enabled
  7. Maps SDK for Android enabled

A) When Android app restriction is set (point 2). I'm getting error:

"google places autocomplete: This IP, site or mobile application is not authorized to use this API key. Request received from IP address xxx.xxx.xxx.xxx, with referrer: undefined"

B) When Android app restriction removed (restriction set to None) everything works fine.

Any ideas?

Android app icon is always smaller than it should be

$
0
0

I have been trying for a long time to create an Android app icon that is the same size as all of the other icons on the device, but my icon is always too small.

I know this is a well documented problem. I have tried every solution I have found but my app icon is still too small.

The posts I have read on Stackoverflow include this, this, this and this.

I have used this tool: Android asset studio. It made the icon too small but that was a know issue. I forked the repo and implemented this fix as documented, but still too small.

I have also tried this tool, this tool and this tool, but they all gave me an icon that showed up as too small on my device.

Then I discovered the tool in Android studio, Image Asset Studio, but unfortunately the icons it produces are too small.

I have tried using a 512 x 512 file in every folder (hdpi / mdpi etc).

I have tried placing them in drawable instead of mipmap.

There is no padding in the source image, the icon reaches the edges of it and is a 512 x 512 png file. I use Android Studio Image Asset Studio to produce the correct sizes.

I place the 48 x 48 in mipmap-hdpi, I place the 72 x 72 in mipmap-mdpi, I place the 96 x 96 in mipmap-xhdpi,I place the 144 x 144 in mipmap-xxhdpi,I place the 192 x 192 in mipmap-xxxhdpi.

I have used various devices, virtual and physical.

Here are the specs of the source image:

enter image description here

Here is the shape of the source image for ic_launcher_round:

enter image description here

I am a Javascript developer using React Native so not very familiar with the Android ecosystem.

How do I make my icon the same size as all the other icons on my phone?

Best slider with full screen and Zoom in and Zoom out option in react native app

$
0
0

Suggest me best slider with full screen and Zoom in and Zoom out option in react native app

App back issue , props is not passed when back and then click on any card in react native app

$
0
0

I have one issue in react native app, When i click on any card then props value is going correctly and then detail page open and when i click back and then click on any card then no props is passed in react native app , same page open with same scrolling position

Viewing all 28469 articles
Browse latest View live


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