React native error in launching app with android emulator - android

I get following error when I run react-native run-android in CMD(windows command prompt)
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
What caused This problem?
Thanks in Advance.

check your device connected or not by execute below command in cmd
adb devices
if adb not found then open below dir
C:\Users\MANGO\AppData\Local\Android\sdk\platform-tools
then check device connected or not
then you can lunch your app
i hope it solve your problem

Set the sdk platform tools path in system variable inside Enviroment variable.
With this you can check the connected devices from command promt.
Note: Make sure you have connected your device to PC with USB debugging On from developer menu. You can follow this link
Then follow following steps.
From command prompt type " adb devices ", if you are connecting the real android device first time then inside your device there will be a RSA key generated which you have to click "OK".
Then to confirm from devices you can again type adb devices if all went good it will show your device.
Move to your project folder from command prompt and then run your app from command prompt.

Related

Not able to connect adb Android Studio to 3.4.1

unable to connect to adb.check the event log for a possible issue, verify that localhost entry is pointing to 127.0.0.1 or:: 1 for ipv4 or ipv6.
Getting an error while running my sample application in android device.
ADB error on a fresh installation of android studio.
Finally I got answer for my own question. This is due to some Windows OS update issue. Please follow the below step to confirm.
Goto C:\Users\bn\AppData\Local\Android\Sdk\platform-tools
Open command prompt from this location and type, adb devices
If you get below error dialog, then the problem is with your windows setup and not any issues with Android Studio.
adb command error
Solution:
Download the package for your Windows version from below link. In my case I have downloaded "All supported x64-based versions of Windows 8.1" package and installed the exe. Once installation is complete check the adb command. It should work.
https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows

adb socket not working and daemon

I am getting this type of error
error: could not install smartsocket listener: cannot bind to
127.0.0.1:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048) 1:34:26
PM could not read ok from ADB Server 1:34:26 PM * failed to start
daemon * 1:34:26 PM error: cannot connect to daemon 1:34:26 PM
'C:\Users\MITESH
SUTHAR\AppData\Local\Android\Sdk\platform-tools\adb.exe,start-server'
failed -- run manually if necessary 1:38:14 PM Unable to obtain result
of 'adb version'
my genymotion device is running but it shows me that no device
I came across the same error. I provided the below command and the issue got solved.
COMMAND :- taskkill /f /im adb.exe
Close Eclipse or Android Studio if either is running (Optional).
Open Command Prompt.
Go to the Android SDK platform-tools directory.
Type adb kill-server.
Type adb start-server.
If no error message is thrown while starting ADB server, then adb is started successfully.
OR
Go to Task Manager, open the Processes tab, and end the adb.exe process.
Then restart Android Studio.
This may work if there is any problem with adb.
In my case, none of the above solution worked. I solved it strangely maybe it can be a bug.
Do not run Genymotion emulator before Android Studio. Firstly, I opened android studio then I clicked run project and select deployment target windows appeared. Then I run genymotion emulator and now the emulator is shown in the select deployment target windows in Android Studio. Then deployed to the emulator without errors. Done!
As another way, you can try to set Genymotion sdk to the same as Android studio sdk. To do this, first find your sdk location. You can find it by right clicking the Android Studio project -> Open Module Settings-> Select SDK location -> under Android SDK location, it is shown. Then open Genymotion -> Settings -> ADB tab -> Click Use custom Android SDK tools radio button -> navigate to SDK folder used by Android studio -> Restart Genymotion virtual device
If none of the above worked for you, just make sure that you have closed Genymotion emulator as it caused this issue with me.
Easiest Way! I just ran into this issue trying to connect a React-Native App to an Android Studio emulator. If you read the error message it tells you that "Only one usage of each socket address (protocol/network address/port) is normally permitted." So you can assume that something other than React-Native is also attempting to connect to the emulator.
Terminate The Connections:
Leave the emulator running.
Close out of and uninstall any Android Studio/Eclipse Apps you have on the emulator. This terminates apps trying to connect.
Close Eclipse or Android Studio if either are running. Android Studio doesn't have to be open in order for the emulator to work (This is important). This terminates software trying to connect.
After doing so I went back into my React-Native App and connected to Expo no problem.
All you have to do is terminate all connections. However you so choose.
I came across the same error, it worked simply after restarting the AS on windows, of course, it asked for SDK update.
Android Studio 4.1.3 with API 30 installation has this error
01-04-2021
09:56 'C:\Users\ranja\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
Tried C:\Users\ranja>adb start-server
daemon not running; starting now at tcp:5037
**could not read ok from ADB Server
failed to start daemon
error: cannot connect to daemon**
Note: I have added 'C:\Users\ranja\Android\Sdk\platform-tools' in %PATH% environment variable on Windows 10
i've encountered same error in my ionic 2. i just uninstall and reinstall ionic. and it works fine again..
npm uninstall -g ionic
npm install -g ionic

React Native 'hello world' quick start: "could not connect to development server"

I'm trying to do the react native 'hello world', and I'm using usb debugging on my android.
I ran react-native run-android, then react-native start.
I can view the js file in localhost, but get 'could not connect to development server' message on my phone.
I followed the instructions to run adb reverse tcp:8081 tcp:8081, then realized that command doesn't exist, so I ran adb forward tcp:8081 tcp:8081 instead.
Still no luck. Using react-native#0.22.0, ubuntu 14.04. My phone is nexus 5 on android 6.0.1.
How can I allow my phone to access my localhost?
By the way, it is working over wifi, but I'd like to get it working over usb.
Just another scenario, this error happened to me when I forgot to run react-native start command. I usually follow the steps here when I start new project. The steps in a nutshell are as follows (Android in my case):
Start Android Studio -> AVD Manager -> select your aVD and click Start from action
inside the directory where you want to create your new project, open your command line and run:
$ react-native init <Your new project name/it is also the registration name>
$ cd <the new directory you created>
$ react-native start //This is the step that I forgot
Open a new command prompt and run the following inside the same directory(you just created) to launch the app on your AVD.
$ react-native run-android
If everything is set up correctly, you should see your new app running in your Android emulator shortly.
You'll find in the file index.android.js in the home directory of your project, the last line contians the App registry using the same name you used in the first command above
adb reverse tcp:8081 tcp:8081 Only works for android 5.0 + for running app on devices with android versions lesser than 5.0 hit following command after npm start is done in Terminal (in app directory folder).
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
now run the app, it will work. Only drawback is that every time you make a change you need to fire the command again and run the app again.
I found the solution :)
I am on ubuntu 16, so, I used command ip addr show which gave me my computer ip address.
I used this ip address and I was able to access localhost on my mobile.
Finally I added the ip address and port no to devsettings of android phone and My app was able to access development server
10 mins ago I had the same problem I guess, and the way I solved this was reading this
https://facebook.github.io/react-native/docs/running-on-device-android.html
and when I did that, I found that I didn't have android-tools-adb installed,
so looking around I found
'No command 'adb' found' error on Ubuntu
which gives me the answer
sudo apt-get install android-tools-adb
and after all this I set
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
then everything works fine, now I can see my app in my Android device.
BTW the option I choose from react native docs was the one that says me
"Using adb reverse
Note that this option is available on devices running Android 5.0+ (API 21).
Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).
Run adb reverse tcp:8081 tcp:8081
You can use Reload JS and other development options with no extra configuration
I am having seen the same issue, and that's all because the android app don't have this permission:
<uses-permission android:name="android.permission.INTERNET" />
I had a similar problem. I would get this error when trying to get it to run on device. It was working fine on my simulators on my computer.
The problem was when I would do adb devices or react-native run-android I would get "ADB is Not Recognized as an internal or external command".
So my fix was to add the path to adb.exe's parent directory to my Environment Variables and then restart my command prompts. After I did that, adb devices would not throw the "unrecognized internal external blah" and it listed my device. I then ran react-native run-android and on startup no more red screen showing the completely useless error message Error calling AppRegistry.runApplication! :)
So I found ADB was located in my folder:
C:\Users\dell\AppData\Local\Android\sdk\platform-tools\adb.exe
I am on a Windows 10 system. dell is my user name of the computer.
So I went to System Environemnt Variables then found "Path" then clicked "Edit", then clicked "New" and added in "C:\Users\dell\AppData\Local\Android\sdk\platform-tools".

Cannot run Android ADB command

I am using Android Studio v0.8.14 to create a an Android Wearable app. Since I am new I am following the instructions from the android site: https://developer.android.com/training/wearables/apps/bt-debugging.html#SetupSession
I was able to pair the wearable (Moto 360) with my handled device (Samsung Galaxy S4. Kitkat OS v4.4.2). As per the instructions provided the next goal is to set the debugging session. Here I am trying to run the adb commands as shown:
adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444
But as soon as I the first command my Android Studio gives me the following errors:
Cannot find file '/Users/Desktop/software/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/forward'
Cannot find file '/Users/Desktop/software/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/tcp'
Cannot find file '/Users/Desktop/software/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/localabstract:/adb-hub'
Can someone please explain me what is am I doing wrong here?
Thanks
Raj
I use this solution in my mac ... just run the command:
export PATH=/Applications/Android\ Studio.app/sdk/tools:/Applications/Android\ Studio.app/sdk/platform-tools:$PATH
It's necessary to run this command every time you open a new terminal. Save this in your path to set permanently..

Where and how runtime error logs are saved in Android device?

While debugging, Log.d() or Log.e() methods come to LogCat, but how do I capture the runtime error or trace log on the Android device when it is not connected to the development environment ?
Works only for rooted phones...They work by executing logcat utility and capturing the stdout (OutputStream). But to execute the logcat utility, you need root rights....
There are more utilities, but here's a sample from OpenIntents...
Logcat reader
It is not saved in your android device when adb is not connected to the developent environment, but you can save your runtime logs in a file
I have tried this and its working for me:: :)
To get the trace/issue logs user has to follow below steps:
1) First, user will be needing to DOWNLOAD AND INSTALL Google Android SDK program along with the Android USB drivers. User can download the Android SDK drivers from here :
"http://developer.android.com/sdk/index.html" ( To get started, download the appropriate package from the table above, then read the guide to Installing the SDK :
"http://developer.android.com/sdk/installing.html") and USB drivers for Windows operating system from here : "http://dl.google.com/android/android_usb_windows.zip".
Installed the Android SDK to PC if not available.
2) Connect the Android device to the PC using USB.
3) Open the Command Prompt ( Terminal on MAC ) and go to the SDK/tools path on prompt (e.g. xyz-Devlop:tools username$, on my mac machine), then execute the
"./adb logcat" on MAC and "adb logcat" on Windows, command on Command Prompt (e.g. xyz-Devlop:tools username$ ./adb logcat, on my mac machine).
4) Run the application on device.
Logs will be then available in the Command Prompt/Terminal.
Enjoy Coding/Debugging...... :)

Categories

Resources