react-native: adb: failed to stat app/build/outputs/apk/app-debug.apk: No such file or directory
How i started my project
react-native init demo && cd demo
react-native run-android --deviceId ZY2243ZMVC
–This caused an error:failed to find the app-debug.apk
–But after Manual installation, it was successful
adb install app-debug.apk
from android/app/build/output/debug/app-debug.apk
Environment
“react”: “^16.0.0”, “react-native”: “0.51.1”, Andriod Sdk: 26.0.2
Expected Behaviour
–Should have installed the apk without any issue –Having Problem with all android devices
Actual Behaviour
**BUILD SUCCESSFUL in 2m 18s**
164 actionable tasks: 3 executed, 161 up-to-date
Running /home/rivertech/Android/Sdk/platform-tools/adb -s ZY2243ZMVC reverse tcp:8081 tcp:8081
adb server version (36) doesn't match this client (39); killing...
* daemon started successfully
Installing the app on the device (cd android && adb -s ZY2243ZMVC install app/build/outputs/apk/app-debug.apk
**adb: failed to stat app/build/outputs/apk/app-debug.apk: No such file or directory**
Command failed: /home/rivertech/Android/Sdk/platform-tools/adb -s ZY2243ZMVC install app/build/outputs/apk/app-debug.apk
**Could not install the app on the device, read the error above for details.**
Starting the app on ZY2243ZMVC (/home/rivertech/Android/Sdk/platform-tools/adb -s ZY2243ZMVC shell am start -n com.demo/com.demo.MainActivity)...
Starting: Intent { cmp=com.demo/.MainActivity }
Error type 3
Error: Activity class {com.demo/com.demo.MainActivity} does not exist.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 15 (2 by maintainers)
I found that running with
--deviceId
parameter cause this problem, when I run onlyreact-native run-android
there’s no problem. Try this:adb -s [deviceId] install android/app/build/outputs/apk/app-debug.apk
I reopen this thick as I guess this is a bug: currently, when building release variant and specifying the deviceId, the debug-apk filename is tried to be installed on the device. This is wrong. In stead, the filename for the release apk should be used.
Should be:
I used this workaround: https://stackoverflow.com/questions/46985530/change-apk-output-folder-in-gradle-4-1/48121314#48121314
For the lost souls of the future: The reason this breaks can also be that you’ve changed
outputFileName
somewhere in a build.gradle file. The apk seems hard-coded toapp-debug.apk
which means React Native will try to install the wrong file. In case you just changed the name, you may see see symptoms of the app not updating.@ysyyork I closed it as a workaround had been posted, and no one left a comment for a few months after that. If you think this should be fixed in the
react-native
CLI, a group of contributors have forked the CLI into a new repo at https://github.com/react-native-community/react-native-cli. Please consider opening an issue there, as the CLI has been removed from this repository.I had the same issue. I think the problem is when android studio starts building this app-debug.apk. For some reason, this directory
android/app/build/output/apk
has child directoriesdebug
andrelease
. This is why react-native-cli throwsNo such file or directory
because it cant find it. The app-debug.apk is indebug
directory.I moved the apk to
android/app/build/output/apk