nativescript-angular: Unable to apply changes on device: Error is: cp: cannot create directory '/platforms/android/app/src': No such file or directory

@gavande commented on Tue Oct 30 2018

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 4.2.4
  • Cross-platform modules:4.2.0
  • Android Runtime:4.2.0
  • iOS Runtime:4.2.0
  • Plugin(s):
  "nativescript": {
    "id": "org.nativescript.cloint",
    "tns-ios": {
      "version": "4.2.0"
    },
    "tns-android": {
      "version": "4.2.0"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~6.1.0",
    "@angular/common": "~6.1.0",
    "@angular/compiler": "~6.1.0",
    "@angular/core": "~6.1.0",
    "@angular/forms": "~6.1.0",
    "@angular/http": "~6.1.0",
    "@angular/platform-browser": "~6.1.0",
    "@angular/platform-browser-dynamic": "~6.1.0",
    "@angular/router": "~6.1.0",
    "nativescript-angular": "~6.1.0",
    "nativescript-camera": "^4.0.3",
    "nativescript-iqkeyboardmanager": "^1.3.0",
    "nativescript-permissions": "^1.2.3",
    "nativescript-secure-storage": "^2.3.0",
    "nativescript-snackbar": "^3.2.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-sidedrawer": "~4.3.0",
    "nativescript-web-image-cache": "^4.2.6",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~6.2.0",
    "tns-core-modules": "~4.2.0",
    "tns-platform-declarations": "^4.2.1",
    "zone.js": "~0.8.18"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~6.1.0",
    "@nativescript/schematics": "~0.3.0",
    "@ngtools/webpack": "~6.2.0",
    "codelyzer": "~4.3.0",
    "nativescript-dev-sass": "~1.6.0",
    "nativescript-dev-typescript": "~0.7.0",
    "nativescript-dev-webpack": "^0.16.0",
    "tslint": "~5.11.0",
    "typescript": "~2.7.2"
  },
  "readme": "NativeScript Application"
}

Describe the bug tns run android --bundle is giving me following error:

Unable to apply changes on device:*. Error is: cp: cannot create directory ‘/platforms/android/app/src’: No such file or directory.

If I delete platforms folder and then run above command then it does not give any error. But once I stop the command and rerun same command gives above error.

Same issue is with iOS platform.

I have deleted node_modules, hooks, platforms folders and then tried to run but same issue.

I have tried upgrade webpack to the latest version but It also didn’t work.

Additional context

Here is console after running command:

~/Projects/production/cloint [requests] $ tns run android --bundle
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Starting Android emulator with image Nexus_5X_API_25
Waiting for emulator device initialization...
Executing before-liveSync hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-watchPatterns hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watchPatterns/nativescript-dev-sass.js
Executing before-watchPatterns hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watchPatterns/nativescript-dev-typescript.js
Executing before-watchPatterns hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watchPatterns/nativescript-dev-webpack.js
Executing before-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watch/nativescript-dev-sass.js
Hook skipped because bundling is in progress.
Executing before-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watch/nativescript-dev-typescript.js
Hook skipped because bundling is in progress.
Executing before-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-watch/nativescript-dev-webpack.js
Running webpack for Android...
clean-webpack-plugin: /Users/rahulgavande/Projects/production/cloint/platforms/android/app/src/main/assets/app/**/* has been removed.
File change detected. Starting incremental webpack compilation...

Webpack is watching the files…

Hash: 68c900ccb3e606cb9949
Version: webpack 4.6.0
Time: 24946ms
Built at: 2018-10-30 11:47:05
                                                                               Asset        Size  Chunks             Chunk Names
  App_Resources/Android/src/main/res/drawable-xhdpi/baseline_arrow_back_white_18.png   171 bytes          [emitted]
                                                                           bundle.js    62.1 KiB  bundle  [emitted]  bundle
                                                                                1.js    6.48 KiB       1  [emitted]
                                                                                2.js    69.6 KiB       2  [emitted]
                                                                           vendor.js    5.05 MiB  vendor  [emitted]  vendor
                                                    App_Resources/Android/app.gradle   549 bytes          [emitted]
                                                 App_Resources/Android/src/.DS_Store       6 KiB          [emitted]
                                  App_Resources/Android/src/main/AndroidManifest.xml    1.36 KiB          [emitted]
                     App_Resources/Android/src/main/res/drawable-hdpi/background.png    3.42 KiB          [emitted]
          App_Resources/Android/src/main/res/drawable-hdpi/baseline_add_white_18.png   150 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-hdpi/baseline_add_white_24.png   138 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-hdpi/baseline_add_white_36.png   158 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-hdpi/baseline_add_white_48.png    97 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-hdpi/baseline_arrow_back_white_18.png   160 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-hdpi/baseline_arrow_back_white_24.png   171 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-hdpi/baseline_arrow_back_white_36.png   176 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-hdpi/baseline_arrow_back_white_48.png   203 bytes          [emitted]
                           App_Resources/Android/src/main/res/drawable-hdpi/icon.png     6.8 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-hdpi/logo.png    32.4 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-hdpi/menu.png   291 bytes          [emitted]
                     App_Resources/Android/src/main/res/drawable-ldpi/background.png    1.31 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-ldpi/icon.png    3.23 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-ldpi/logo.png    9.95 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-ldpi/menu.png   213 bytes          [emitted]
                     App_Resources/Android/src/main/res/drawable-mdpi/background.png    1.89 KiB          [emitted]
          App_Resources/Android/src/main/res/drawable-mdpi/baseline_add_white_18.png   102 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-mdpi/baseline_add_white_24.png    92 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-mdpi/baseline_add_white_36.png   138 bytes          [emitted]
          App_Resources/Android/src/main/res/drawable-mdpi/baseline_add_white_48.png    97 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-mdpi/baseline_arrow_back_white_18.png   128 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-mdpi/baseline_arrow_back_white_24.png   132 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-mdpi/baseline_arrow_back_white_36.png   171 bytes          [emitted]
   App_Resources/Android/src/main/res/drawable-mdpi/baseline_arrow_back_white_48.png   170 bytes          [emitted]
                           App_Resources/Android/src/main/res/drawable-mdpi/icon.png    3.42 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-mdpi/logo.png    15.8 KiB          [emitted]
                           App_Resources/Android/src/main/res/drawable-mdpi/menu.png   235 bytes          [emitted]
                 App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml   304 bytes          [emitted]
                    App_Resources/Android/src/main/res/drawable-xhdpi/background.png    5.26 KiB          [emitted]
         App_Resources/Android/src/main/res/drawable-xhdpi/baseline_add_white_18.png   138 bytes          [emitted]
         App_Resources/Android/src/main/res/drawable-xhdpi/baseline_add_white_24.png    97 bytes          [emitted]
         App_Resources/Android/src/main/res/drawable-xhdpi/baseline_add_white_36.png    97 bytes          [emitted]
         App_Resources/Android/src/main/res/drawable-xhdpi/baseline_add_white_48.png   102 bytes          [emitted]
                                                                                0.js    11.8 KiB       0  [emitted]
  App_Resources/Android/src/main/res/drawable-xhdpi/baseline_arrow_back_white_24.png   170 bytes          [emitted]
  App_Resources/Android/src/main/res/drawable-xhdpi/baseline_arrow_back_white_36.png   203 bytes          [emitted]
  App_Resources/Android/src/main/res/drawable-xhdpi/baseline_arrow_back_white_48.png   261 bytes          [emitted]
                          App_Resources/Android/src/main/res/drawable-xhdpi/icon.png    10.4 KiB          [emitted]
                          App_Resources/Android/src/main/res/drawable-xhdpi/logo.png      54 KiB          [emitted]
                          App_Resources/Android/src/main/res/drawable-xhdpi/menu.png   297 bytes          [emitted]
                   App_Resources/Android/src/main/res/drawable-xxhdpi/background.png    10.3 KiB          [emitted]
        App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_add_white_18.png   158 bytes          [emitted]
        App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_add_white_24.png    97 bytes          [emitted]
        App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_add_white_36.png   186 bytes          [emitted]
        App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_add_white_48.png   113 bytes          [emitted]
 App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_arrow_back_white_18.png   176 bytes          [emitted]
 App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_arrow_back_white_24.png   203 bytes          [emitted]
 App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_arrow_back_white_36.png   253 bytes          [emitted]
 App_Resources/Android/src/main/res/drawable-xxhdpi/baseline_arrow_back_white_48.png   275 bytes          [emitted]
                         App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png    20.3 KiB          [emitted]
                         App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png     116 KiB          [emitted]
                         App_Resources/Android/src/main/res/drawable-xxhdpi/menu.png   378 bytes          [emitted]
                  App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png    3.87 KiB          [emitted]
       App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_add_white_18.png    97 bytes          [emitted]
       App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png   102 bytes          [emitted]
       App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_add_white_36.png   113 bytes          [emitted]
       App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_add_white_48.png   116 bytes          [emitted]
App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_arrow_back_white_18.png   203 bytes          [emitted]
App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_arrow_back_white_24.png   261 bytes          [emitted]
App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_arrow_back_white_36.png   275 bytes          [emitted]
App_Resources/Android/src/main/res/drawable-xxxhdpi/baseline_arrow_back_white_48.png   408 bytes          [emitted]
                        App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png    73.8 KiB          [emitted]
                        App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png     193 KiB          [emitted]
                        App_Resources/Android/src/main/res/drawable-xxxhdpi/menu.png   466 bytes          [emitted]
                     App_Resources/Android/src/main/res/drawable/baseline_add_24.xml   384 bytes          [emitted]
              App_Resources/Android/src/main/res/drawable/baseline_arrow_back_24.xml   411 bytes          [emitted]
                            App_Resources/Android/src/main/res/values-v21/colors.xml   104 bytes          [emitted]
                            App_Resources/Android/src/main/res/values-v21/styles.xml  1020 bytes          [emitted]
                                App_Resources/Android/src/main/res/values/colors.xml   237 bytes          [emitted]
                                App_Resources/Android/src/main/res/values/styles.xml    1.68 KiB          [emitted]
                                                               fonts/FontAwesome.ttf     162 KiB          [emitted]
                                                               assets/login-logo.png    11.8 KiB          [emitted]
                                                                     assets/logo.png    16.3 KiB          [emitted]
                                                                        package.json    82 bytes          [emitted]
                                                                          starter.js    39 bytes          [emitted]
                                                                 tns-java-classes.js     0 bytes          [emitted]
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.scss] 21.3 KiB {bundle} [built]
[./app/app-routing.module.ts] 791 bytes {bundle} [built]
[./app/app.component.html] 3.18 KiB {bundle} [built]
[./app/app.component.ts] 4.64 KiB {bundle} [built]
[./app/app.config.ts] 1.89 KiB {bundle} [built]
[./app/app.http-interceptor.ts] 1.4 KiB {bundle} [built]
[./app/app.module.ts] 1.33 KiB {bundle} [built]
[./app/login/login.module.ts] 773 bytes {0} [built]
[./main.ts] 620 bytes {bundle} [built]
[./package.json] 82 bytes {bundle} [optional] [built]
[./services/feedback.service.ts] 552 bytes {bundle} [built]
[./services/login.service.ts] 1.95 KiB {bundle} [built]
[./services/master.service.ts] 1.18 KiB {bundle} [built]
[./services/storage.service.ts] 1.22 KiB {bundle} [built]
    + 472 hidden modules
Webpack compilation complete. Watching for file changes.
Webpack build done!
Executing before-shouldPrepare hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Executing before-cleanApp hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-cleanApp/nativescript-dev-webpack.js
Executing before-prepare hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-prepare/nativescript-dev-sass.js
Hook skipped because either bundling or livesync is in progress.
Executing before-prepare hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-prepare/nativescript-dev-typescript.js
Hook skipped because either bundling or livesync is in progress.
Preparing project...
Executing before-prepareJSApp hook from /Users/rahulgavande/Projects/production/cloint/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Gradle clean...
         + setting applicationId
         + applying user-defined configuration from /Users/rahulgavande/Projects/production/cloint/App_Resources/Android/app.gradle
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/rahulgavande/Projects/production/cloint/node_modules/nativescript-camera/platforms/android/nativescript_camera.aar
         + adding aar plugin dependency: /Users/rahulgavande/Projects/production/cloint/node_modules/nativescript-ui-sidedrawer/platforms/android/TNSSideDrawer-release.aar
         + adding aar plugin dependency: /Users/rahulgavande/Projects/production/cloint/node_modules/nativescript-web-image-cache/platforms/android/nativescript_web_image_cache.aar
         + adding aar plugin dependency: /Users/rahulgavande/Projects/production/cloint/node_modules/nativescript-ui-core/platforms/android/TNSCore-release.aar
         + adding aar plugin dependency: /Users/rahulgavande/Projects/production/cloint/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
Unable to apply changes on device: emulator-5554. Error is: cp: cannot create directory '/Users/rahulgavande/Projects/production/cloint/platforms/android/app/src': No such file or directory.
Executing after-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/after-watch/nativescript-dev-sass.js
Executing after-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/after-watch/nativescript-dev-typescript.js
Executing after-watch hook from /Users/rahulgavande/Projects/production/cloint/hooks/after-watch/nativescript-dev-webpack.js
Stopping webpack watch 

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

Can this be re-opened? I also have to run tns platform clean android in my NativeScript-Angular project before running any tns debug android – huge burden when testing across multiple devices. This will also happen when doing something like:

tns platform clean android tns debug android --bundle --device some-device <-- Successful tns debug android --bundle --device some-other-device <-- Executed in a different terminal window, fails

Whether or not that flow is appropriate, I think it may also hint at a failed attempt to access locked/corrupt files.

NativeScript CLI 6.0.2 tns-ios / tns-android 6.0.1

"dependencies": {
  "@angular/animations": "~8.0.0",
  "@angular/common": "~8.0.0",
  "@angular/compiler": "~8.0.0",
  "@angular/core": "~8.0.0",
  "@angular/forms": "~8.0.0",
  "@angular/http": "~8.0.0-beta.10",
  "@angular/platform-browser": "~8.0.0",
  "@angular/platform-browser-dynamic": "~8.0.0",
  "@angular/router": "~8.0.0",
  "nativescript-angular": "~8.0.0",
  "nativescript-oauth2": "^1.4.3",
  "nativescript-theme-core": "~1.0.6",
  "nativescript-ui-dataform": "5.0.0",
  "nativescript-ui-gauge": "5.0.0",
  "nativescript-ui-listview": "7.0.1",
  "reflect-metadata": "~0.1.12",
  "rxjs": "~6.5.0",
  "rxjs-compat": "^6.5.2",
  "tns-core-modules": "~6.0.0",
  "zone.js": "~0.9.1"
},
"devDependencies": {
  "@angular/compiler-cli": "~8.0.0",
  "@ngtools/webpack": "~8.0.0",
  "nativescript-dev-webpack": "~1.0.0",
  "typescript": "~3.4.0"
}