android-js / androidjs

Platform to build android app using node js
MIT License
464 stars 110 forks source link

androidjs init fails to create project, operation not permitted rename #68

Open jtoppine opened 4 years ago

jtoppine commented 4 years ago

Androidjs init fails to create a project. It stops to a permission error when renaming vue-js-example, and is unable to handle the error.

Tried this with two different Win10 machines, both administrator and regular CMD, updated node, updated npm, updated all global packages, cleared npm caches, tried to set very permissive folder permissions on windows, disabled windows defender, disabled dropbox, tried this outside dropbox folder, and many other things I can't remember anymore.

To Reproduce Steps to reproduce the behavior:

  1. Install androidjs: npm i -g androidjs-builder
  2. Create project: androidjs init (give project any name and press enter to continue)
  3. See error

Desktop (please complete the following information):

C:\Users\[redacted]\platform\androidjs>androidjs init
                     _           _     _        _  _____
     /\             | |         (_)   | |      | |/ ____|
    /  \   _ __   __| |_ __ ___  _  __| |      | | (___
   / /\ \ | '_ \ / _` | '__/ _ \| |/ _` |  _   | |\___ \
  / ____ \| | | | (_| | | | (_) | | (_| | | |__| |____) |
 /_/    \_\_| |_|\__,_|_|  \___/|_|\__,_|  \____/|_____/

? Application name: mswing
? Project type: HTML/CSS
Testing 'Theme Update' ...
Creating Native app at C:\Users\[redacted]\platform\androidjs
Downloading Sample Project From:
https://raw.githubusercontent.com/android-js/sample-app/master/vue-js-example
Downloading ... ⠐  [ 'vue-js-example/.gitignore',
  'vue-js-example/README.md',
  'vue-js-example/assets/androidjs.js',
  'vue-js-example/assets/bootstrap.min.css',
  'vue-js-example/assets/bootstrap.min.js',
  'vue-js-example/assets/icon/courses-icon-10.png',
  'vue-js-example/assets/icon/ic_launcher.png',
  'vue-js-example/assets/icon/icon.png',
  'vue-js-example/assets/jquery-3.3.1.slim.min.js',
  'vue-js-example/assets/popper.min.js',
  'vue-js-example/assets/script.js',
  'vue-js-example/main.js',
  'vue-js-example/node_modules/Buffer/README.md',
  'vue-js-example/node_modules/Buffer/index.js',
  'vue-js-example/node_modules/Buffer/package.json',
  'vue-js-example/node_modules/accepts/HISTORY.md',
[removed many lines for brevity]
  'vue-js-example/node_modules/blob/.idea/markdown-navigator/profiles_settings.xml',
  'vue-js-example/node_modules/blob/.idea/modules.xml',
  'vue-js-example/node_modules/blob/.idea/vcs.xml',
  'vue-js-example/node_modules/blob/.idea/workspace.xml',
  ... 303 more items,
  truncated: false ]
1/403 ✔ vue-js-example/README.md
2/403 ✔ vue-js-example/.gitignore
3/403 ✔ vue-js-example/node_modules/androidjs/docs/ipc.md
4/403 ✔ vue-js-example/node_modules/androidjs/example/index.html
5/403 ✔ vue-js-example/node_modules/androidjs/docs/packaging_app.md
6/403 ✔ vue-js-example/node_modules/arraybuffer.slice/.npmignore
7/403 ✔ vue-js-example/node_modules/androidjs/lib/back.js
[removed many lines for brevity]
400/403 ✔ vue-js-example/node_modules/socket.io-client/dist/socket.io.slim.dev.js.map
401/403 ✔ vue-js-example/node_modules/socket.io-client/dist/socket.io.dev.js.map
402/403 ✔ vue-js-example/node_modules/socket.io-client/dist/socket.io.slim.js.map
403/403 ✔ vue-js-example/node_modules/socket.io-client/dist/socket.io.js.map
example downloaded
fs.js:115
    throw err;
    ^

Error: EPERM: operation not permitted, rename 'C:\Users\[redacted]\platform\androidjs\vue-js-example' -> 'C:\Users\[redacted]\platform\androidjs\mswing'
    at Object.renameSync (fs.js:594:3)
    at copy.fromGithub.to (C:\Users\[redacted]\AppData\Roaming\npm\node_modules\androidjs-builder\lib\native_app.js:45:20)
    at Request.request [as _callback] (C:\Users\[redacted]\AppData\Roaming\npm\node_modules\androidjs-builder\lib\copy.js:115:44)
    at Request.self.callback (C:\Users\[redacted]\AppData\Roaming\npm\node_modules\androidjs-builder\node_modules\request\request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.<anonymous> (C:\Users\[redacted]\AppData\Roaming\npm\node_modules\androidjs-builder\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:194:15)
    at IncomingMessage.<anonymous> (C:\Users\[redacted]\AppData\Roaming\npm\node_modules\androidjs-builder\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
    at IncomingMessage.emit (events.js:194:15)
Chhekur commented 4 years ago

Sometime this happens in windows machine, so you can manually change the name 😅

jtoppine commented 4 years ago

Sometime this happens in windows machine, so you can manually change the name 😅

Ok, thank you. However it seems to not execute actions after that error. If I read correctly, after renaming, androidjs init tries at least to update package.json:


                 pkg['name'] = this.androidjs.project.name;
                 pkg['app-name'] = this.androidjs.project.name;
                 pkg['package-name'] = this.androidjs.project.name;

                 pkg['scripts']['install'] = "adb install ./dist/app.apk";
                 pkg['scripts']['run'] = `adb shell am start -n com.android.js.${this.androidjs.project.name}/com.android.js.webview.MainActivity`;
                 pkg['scripts']['build:run'] = "androidjs build && npm run install && npm run run";
                 pkg['theme'] = {
                    "fullScreen": true,
                    "colorAccent": "@color/colorAccent",
                    "colorPrimary": "@color/colorPrimary",
                    "colorPrimaryDark": "@color/colorPrimaryDark"
                };

                 jsonfile.writeFileSync(path.join(this.androidjs.project.paths.__dirname, this.androidjs.project.name, 'package.json'), pkg, { spaces: 4 })

Those actions won't get done because of the unhandled exception. I can do those changes manually too, I guess. Not sure if there is something else that should be done to create a working new project. Androidjs build fails on that newly created, manually renamed project though ("Error: total required at new ProgressBar ", a problem that seems to have it's own submission here on the issue tracker..)

Chhekur commented 4 years ago

Error: total required error occurs when your internet is slow or unavailable.

In order to overcome this error repeatedly try build command until it start fetching sdk

jtoppine commented 4 years ago

Error: total required error occurs when your internet is slow or unavailable.

In order to overcome this error repeatedly try build command until it start fetching sdk

Yes, this seems to work as a workaround!

ghost commented 4 years ago

This is still a problem and it has nothing to do with the internet connection. If I run androidjs init on Ubuntu, on the same machine and same internet connection, it works fine on the first try. On Windows it doesn't work even on a datacenter connection.

jughead101 commented 4 years ago

Facing the same issue ...

Chhekur commented 4 years ago

This bug is gonna fix in the new release, which you'll get very soon ; )

Chhekur commented 4 years ago

Hey, we have release new version of androidjs-builder@2.1.4, which may solve all the existing problem. So you can upgrade to the latest version 2.1.4 and enjoy.

Follow these instruction to upgrade androidjs-builder to latest

$ npm uninstall -g androidjs-builder
$ npm install -g androidjs-builder@2.1.4

Feel free to ask in case of any problem ; )

jughead101 commented 4 years ago

Hi Chhekur,

Getting the following error:

loadDep:yargs → resolveWi ▌ ╢██████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟ npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 loadDep:fsevents → 304 ▐ ╢████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟ npm ERR! Linux 4.4.0-18362-Microsoft npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "androidjs-builder@2.1.4" npm ERR! node v8.10.0 npm ERR! npm v3.5.2 npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1 npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3) npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22) npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12) npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7 npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12 npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5) npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7) npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20) npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror This is an error with npm itself. Please report this error at: npm ERR! typeerror http://github.com/npm/npm/issues

Regards, Amit

jughead101 commented 4 years ago

Hi Chhekur,

Getting the following error:

loadDep:yargs → resolveWi ▌ ╢██████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟ npm WARN deprecated request@2.88.2: request has been deprecated, see request/request#3142 loadDep:fsevents → 304 ▐ ╢████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟ npm ERR! Linux 4.4.0-18362-Microsoft npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "androidjs-builder@2.1.4" npm ERR! node v8.10.0 npm ERR! npm v3.5.2 npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1 npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3) npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22) npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12) npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7 npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12 npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5) npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7) npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20) npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50 npm ERR! typeerror This is an error with npm itself. Please report this error at: npm ERR! typeerror http://github.com/npm/npm/issues

Regards, Amit

Installing the latest NPM solved the issue ...

npm install -g npm@latest

jughead101 commented 4 years ago

failing at build now:

androidjs build

copying assets ... updating app name... updating theme ... Using SDK: 2.0.4 Building Apk ... events.js:183 throw er; // Unhandled 'error' event ^

Error: spawn java ENOENT at _errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! firstApp@1.0.0 build: androidjs build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the firstApp@1.0.0 build script.

jughead101 commented 4 years ago

failing at build now:

androidjs build

copying assets ... updating app name... updating theme ... Using SDK: 2.0.4 Building Apk ... events.js:183 throw er; // Unhandled 'error' event ^

Error: spawn java ENOENT at _errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! firstApp@1.0.0 build: androidjs build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the firstApp@1.0.0 build script.

Ok.. .solved it apt install default-jre

Chhekur commented 4 years ago

Hey, we have created a slack channel for support & discussion: join here