Error: ENOENT: no such file or directory, open 'platforms/android/app/build/outputs/apk/debug/app-debug.apk'

Hello,

I have created an app with ionic v3. I am facing issue while running live reload build on a real android device.

> cordova build android --device
[app-scripts] [03:03:34]  lint finished in 19.00 s 
> native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --connect --forward 8100:8100
[native-run] Selected hardware device 8a0ad564
[native-run] Error: ENOENT: no such file or directory, open 'platforms/android/app/build/outputs/apk/debug/app-debug.apk'
[ERROR] An error occurred while running subprocess native-run.
        
        native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug... exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

initially, when it was running, that time the debug apk file path was
’platforms/android/build/outputs/apk/android-debug.apk’

but not the path is
’platforms/android/app/build/outputs/apk/debug/app-debug.apk’

I am not able to figure it out exactly what is the cause, I have tried by upgrading versions of these - cordova, ionic-cli, native-run, cordova-android, Android Studio

Here is the ionic info

$ ionic info
       
Ionic:

   Ionic CLI          : 5.0.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.7

Cordova:

   Cordova CLI       : 7.0.0
   Cordova Platforms : android 6.4.0, ios 4.5.4
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 1.2.1, (and 15 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.6

System:

   NodeJS : v11.11.0 (/usr/local/bin/node)
   npm    : 6.7.0
   OS     : macOS High Sierra
   Xcode  : Xcode 10.1 Build version 10B61

Can you try reinstalling platform?

First, remove platform by this command

ionic cordova platform rm android 

Upgrade cordova-android@7 with root user

sudo npm install -g cordova-android@7

Add android platform

ionic cordova platform add android 
1 Like

Thanks, I have removed the platform, upgraded the cordova-android@7 and installed platform again but ends with the same error

> cordova build android --device
[app-scripts] [19:35:21]  lint finished in 15.68 s 
> native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --connect --forward 8100:8100
[native-run] Selected hardware device 8a0ad564
[native-run] Error: ENOENT: no such file or directory, open 'platforms/android/app/build/outputs/apk/debug/app-debug.apk'
[ERROR] An error occurred while running subprocess native-run.
        
        native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug... exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

Same here. Platform 6.4

Please share log when you add platform android.

ionic cordova platform add android

I’ve got fixed that. I dont know why but on my package.json the ionic dependency was ^5.2, I’ve changed to ^1.0.0 and run npm install. Now the command is working like a charm.

I tried this all but still error.