coding_Lover
coding_Lover

Reputation: 443

react-native hellow world app - working in emulator but not in physical device

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

Upvotes: 0

Views: 2066

Answers (3)

Himalay
Himalay

Reputation: 262

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

Upvotes: 0

user9846301
user9846301

Reputation:

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 

Upvotes: 0

pho mai
pho mai

Reputation: 194

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

Upvotes: 1

Related Questions