0

I'm new to React-native and i create my first hello world program. In android studio emulator it works fine. Emulator shows

I used following commands

react-native start
react-native run-android

enter image description here

But when i get the app-debug.apk file from output folder and install in my physical mobile phone it gives following error. (This is a screenshot)

enter image description here

Have i done wrong somewhere?

Thank you

coding_Lover
  • 393
  • 1
  • 4
  • 13
  • The problem is that app can not connect to development server. If you'd like to install apk file to your physical devices, you have to build in release mode. Or you should set `Debug server host & port` to your machine. – Tuan Luong Feb 15 '20 at 04:46

3 Answers3

1

https://facebook.github.io/react-native/docs/running-on-device follow these steps, don't copy an apk file.

pho mai
  • 184
  • 3
0

Add this line in package.json

script:{
--
 "android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
}

and run this command :

adb reverse tcp:8081 tcp:8081 
react-native run-android 
0

i suggest to use this steps to run your apk from this answer

These steps really help me:

Step 1: Create a directory in android/app/src/main/assets

Linux command: mkdir android/app/src/main/assets

Step 2: Rename index.android.js (in root directory) to index.js (Maybe there is an index.js file in which case you do not need to rename it) then run the following command:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Step 3: Build your APK: react-native run-android

Himalay
  • 162
  • 1
  • 13