React-native: cannot run app on Android 4.4 device

Created on 20 Sep 2015  路  16Comments  路  Source: facebook/react-native

I am trying with React Native Android for the awesome project. It was successful running under emulator while fail with the real device with android 4.4. Here below is the output:

...
Installed on 1 device.

BUILD SUCCESSFUL

Total time: 10.449 secs

This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
Starting the app (adb shell am start -n com.awesomeproject/.MainActivity)...
Starting: Intent { cmp=com.awesomeproject/.MainActivity }
Error type 3
Error: Activity class {com.awesomeproject/com.awesomeproject.MainActivity} does not exist.

_Can anyone give a hint?_

Locked

Most helpful comment

The documentation provided is for Android 5.0 and above as adb reverse works only from Android 5.0 and above.
I got a "Unable to download JS bundle" error on the device when I tried to run it on a KitKat device
I solved it by building the bundle file using the command

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

followed by react-native run-android
(Create the necessary folders if they don't exist)
The only problem being that I have build and run every time I make a change

All 16 comments

I also got this problem

The documentation provided is for Android 5.0 and above as adb reverse works only from Android 5.0 and above.
I got a "Unable to download JS bundle" error on the device when I tried to run it on a KitKat device
I solved it by building the bundle file using the command

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

followed by react-native run-android
(Create the necessary folders if they don't exist)
The only problem being that I have build and run every time I make a change

@NishanthShankar The problem I met is the application is not started (using USB Debugging mode). I encountered "Unable to download JS bundle" error when I played with the emulator. And it was solved by "brew update watchman". Worth to have a try to avoid manual building every time.

@rogerwq . Yeah I had to update watchman to get it running on the emulator too. But that doesn't seem to work for the device. I guess a fix for the same is in the pipeline. I'm not sure why the app fails to launch.

@rogerwq By any chance do you have more than one device connected (e.g. real device + emulator). What is the output of adb devices when you get the error you've posted?

Also for running on device <5.0 please refer to this section: http://facebook.github.io/react-native/docs/running-on-device-android.html#configure-device-to-connect-to-the-dev-server-via-wi-fi

@kmagiera there is only 1 real device.

List of devices attached 
phone-id    device

The "wifi" approach seems impossible for me. I have no _rage shake menu_ since there is no app launched in real device. Even the console says _Installed on 1 device_, I cannot find any icon of the installed app.

Any further suggestion?

  1. Do you have USB debugging enabled on your device: http://facebook.github.io/react-native/docs/running-on-device-android.html#usb-debugging
  2. Try building app manually using gradle: cd android and ./gradlew :app:installDebug
  3. If the above fails try running adb command to install apk (should provide more output) from android dir in your project: adb install app/build/outputs/apk/app-debug.apk

@kmagiera thanks for the suggestions. Both option 1 and 2 installed the app on my phone but I still see the red screen with "Unable to download JS bundle".

@kmagiera Great thanks for the support.

I got the white screen with "Welcome to React Native" finally by building, installing manually the apk file and connecting to dev server via wifi.

The same issue caused by the short of system storage.

adb install app/build/outputs/apk/app-debug.apk

will get the error msg, but gradle install will not.

@NishanthShankar you save me a lot. Thanks

@NishanthShankar You can set the development server ip:port on the app_menu>"Dev Settings">"Debug server host & port for device" in order to reload via wifi.

Also guys check if you have nice permissions for your android/gradlew directory, that was my problem.

chmod 755 android/gradlew

I was facing this issue after installing-uninstalling a release version of the RN app on my device. I was no longer able to do a yarn android.

I solved it with @kmagiera suggested solution (#3: from android dir in your project: adb install app/build/outputs/apk/app-debug.apk). Thanks

In my case with Android 4.4.2 had to do what @NishanthShankar had suggested and some additional steps:
(Make sure rn server is running npm start, delete app-debug.apk from android/app/build/outputs/apk , uninstall from android if previously installed and run following commands from root folder)

1_ create dir mkdir android/app/src/main/assets
2_ create file index.android.js which is a clone of index.js cp index.js index.android.js
3_ react-native link
4_ curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
5_ react-native run-android

Was this page helpful?
0 / 5 - 0 ratings