Can’t run first app. HelloWorld. Tutorial


#1

I check the correctness of the system configuration, the following command

$ tns doctor
NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

Your components are up-to-date.

No issues were detected.

Create app

$ tns create HelloWorld --template nativescript-template-tutorial

Installing  nativescript-template-tutorial
/DATA/PROJECTS/NS/HelloWorld
└─┬ nativescript-template-tutorial@3.1.0 
  ├── nativescript-theme-core@1.0.4 
  └─┬ tns-core-modules@3.1.0 
    └── tns-core-modules-widgets@3.1.0 

/DATA/PROJECTS/NS/HelloWorld
└── tns-template-hello-world@3.1.0 

Project HelloWorld was successfully created.

Сheck my devices. I do on the real device and on the emulator

$ tns devices

Connected devices & emulators
Searching for devices...
iTunes is not available for this operating system. You will not be able to work with connected iOS devices.
┌───┬─────────────┬──────────┬───────────────────┬────────┬───────────┐
│ # │ Device Name │ Platform │ Device Identifier │ Type   │ Status    │
│ 1 │ A2010-a     │ Android  │ HKL104YU          │ Device │ Connected │
└───┴─────────────┴──────────┴───────────────────┴────────┴───────────┘

Trying to launch it

$ tns run android --device 1

And I have an error

Searching for devices...
iTunes is not available for this operating system. You will not be able to work with connected iOS devices.
Your application will be deployed only on the device specified by the provided index or identifier.
Copying template files...
  ◟ Installing tns-androidInstalling  tns-android
/DATA/PROJECTS/NS/HelloWorld
└── tns-android@3.1.1 

  ◟ Installing tns-android[    ..............] - fetchMetadata: sill mapToRegistry uri https://registry.npmjs
......
......
......
Project successfully created.
Preparing project...
Unable to apply changes on device: HKL104YU. Error is: Processing node_modules failed. Error: spawn EACCES.

Error Text
"Unable to apply changes on device: HKL104YU. Error is: Processing node_modules failed. Error: spawn EACCES."

How to solve this?
I am newbie. Thank you.

PS
nodejs --version
v6.11.1

npm --version
3.10.10

tns --version
3.1.2

PSS

I ran it with the key
$ tns run android - log trace

Unable to apply changes on device: emulator-5554. Error is: cp: copyFileSync: could not write to dest file (code = EACCES): / DATA / PROJECTS / NS / HelloWorld / platforms / android / src / main / AndroidManifest.xml.


#2

And after changing the rights of the AndroidManifest.xml file

Preparing project...
spawn: node "/DATA/PROJECTS/NS/HelloWorld/platforms/android/build-tools/check-v8-dependants.js" "[{"name":"nativescript-theme-core","directory":"/DATA/PROJECTS/NS/HelloWorld/node_modules/nativescript-theme-core","depth":0,"nativescript":{"platforms":{"ios":"2.4.0","android":"2.4.0"}},"dependencies":[]},{"name":"tns-core-modules","directory":"/DATA/PROJECTS/NS/HelloWorld/node_modules/tns-core-modules","depth":0,"nativescript":{"platforms":{"ios":"3.0.0","android":"3.0.0"}},"dependencies":["tns-core-modules-widgets"]},{"name":"tns-core-modules-widgets","directory":"/DATA/PROJECTS/NS/HelloWorld/node_modules/tns-core-modules-widgets","depth":0,"nativescript":{"platforms":{"ios":"2.0.0","android":"2.0.0"}},"dependencies":[]}]" "/DATA/PROJECTS/NS/HelloWorld/platforms"
spawn: ./gradlew "clean" "-PcompileSdk=android-25" "-PtargetSdk=__APILEVEL__" "-PbuildToolsVersion=25.0.2" "-PsupportVersion=25.3.1" "-PgenerateTypings=false"
{ Error: spawn EACCES
    at exports._errnoException (util.js:1018:11)
    at ChildProcess.spawn (internal/child_process.js:319:11)
    at Object.exports.spawn (child_process.js:378:9)
    at ChildProcess.spawn (/usr/lib/node_modules/nativescript/lib/common/child-process.js:57:30)
    at Promise (/usr/lib/node_modules/nativescript/lib/common/child-process.js:65:37)
    at ChildProcess.spawnFromEvent (/usr/lib/node_modules/nativescript/lib/common/child-process.js:64:16)
    at AndroidProjectService.<anonymous> (/usr/lib/node_modules/nativescript/lib/services/android-project-service.js:414:39)
    at next (native)
    at /usr/lib/node_modules/nativescript/lib/services/android-project-service.js:7:65
    at __awaiter (/usr/lib/node_modules/nativescript/lib/services/android-project-service.js:3:12) code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
Processing node_modules failed. Error: spawn EACCES
Unable to apply changes on device: emulator-5554. Error is: Processing node_modules failed. Error: spawn EACCES.

#3

An error is generated in the file
/usr/lib/nodejs/util.js

In this code (1018:11)

exports._errnoException = function(err, syscall, original) {
  var errname = uv.errname(err);
  var message = `${syscall} ${errname}`;
  if (original)
    message += ' ' + original;
  var e = new Error(message);  <-- ERROR
  e.code = errname;
  e.errno = errname;
  e.syscall = syscall;
  return e;
};

#4

Google search this error.

https://github.com/NativeScript/sample-android-background-services/issues/1 seems to indicate that maybe gradle doesn’t have the execute flag set? A lot of the other posts show that it is a permission issue either on gradle or another file.


#5

gradlew is executable

$ pwd
/DATA/PROJECTS/NS/HelloWorld/platforms/android
$ ls -la
итого 68
drwxrwxr-x 6 tux tux  4096 июл 19 16:50 .
drwxrwxr-x 3 tux tux  4096 июл 19 16:50 ..
-rw-rw-r-- 1 tux tux 22697 июл 19 16:50 build.gradle
drwxrwxr-x 4 tux tux  4096 июл 19 16:50 build-tools
drwxrwxr-x 3 tux tux  4096 июл 19 16:50 gradle
-rw-rw-r-- 1 tux tux    62 июл 19 16:50 gradle.properties
-rwxrwxr-x 1 tux tux  5299 июл 19 16:50 gradlew
-rw-rw-r-- 1 tux tux  2176 июл 19 16:50 gradlew.bat
drwxrwxr-x 3 tux tux  4096 июл 19 16:50 libs
-rw-rw-r-- 1 tux tux   225 июл 19 16:51 settings.gradle
drwxrwxr-x 4 tux tux  4096 июл 19 16:50 src


I still can't start first app. Continued
#6

then I run

tux@pc /HelloWorld/platforms/android $ ./gradlew
bash: ./gradlew: Permission denied
tux@pc /HelloWorld/platforms/android $ sudo ./gradlew
sudo: unable to execute ./gradlew: Permission denied