Skip to content

semver copied to platforms/android even though it's a dev dependency #1802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hdeshev opened this issue Jun 3, 2016 · 7 comments
Closed
Labels
Milestone

Comments

@hdeshev
Copy link
Contributor

hdeshev commented Jun 3, 2016

This one happens semi-randomly in Angular projects. It seems we sometimes end up with multiple copies of semver.js.gz inside the android platform directory, which causes an error with the android AAPT tool (error below).

I verified that I don't get a semver package in node_modules by running a npm install --production, which means semver is a dev dependency. It seems it should never ever get copied to platforms/android.

Steps to reproduce:

  1. Checkout this nativescript-angular tree: https://github.com/NativeScript/nativescript-angular/tree/814a8b4d1f657a0d670ea25cc3b2372c1f5cd4fc
  2. cd nativescript-angular && npm link && npm install && ./node_modules/.bin/tsc
  3. cd tests
  4. npm link nativescript-angular
  5. tns run android

:processF0DebugResources
Executing task ':processF0DebugResources' (up-to-date check took 0.1 secs) due to:
  No history is available.
All input files are considered out-of-date for incremental task ':processF0DebugRes
ources'.
Starting process 'command '/opt/android-sdk-linux/build-tools/23.0.1/aapt''. Workin
g directory: /home/local/TELERIK/hdeshev/w/nativescript-angular/tests/platforms/and
roid Command: /opt/android-sdk-linux/build-tools/23.0.1/aapt package -f --no-crunch
 -I /opt/android-sdk-linux/platforms/android-23/android.jar -M /home/local/TELERIK/
hdeshev/w/nativescript-angular/tests/platforms/android/build/intermediates/manifest
s/full/F0/debug/AndroidManifest.xml -S /home/local/TELERIK/hdeshev/w/nativescript-a
ngular/tests/platforms/android/build/intermediates/res/merged/F0/debug -A /home/loc
al/TELERIK/hdeshev/w/nativescript-angular/tests/platforms/android/build/intermediat
es/assets/F0/debug -m -J /home/local/TELERIK/hdeshev/w/nativescript-angular/tests/p
latforms/android/build/generated/source/r/F0/debug -F /home/local/TELERIK/hdeshev/w
/nativescript-angular/tests/platforms/android/build/intermediates/res/resources-F0-
debug.ap_ --debug-mode --custom-package org.nativescript.helloworldng -0 apk --outp
ut-text-symbols /home/local/TELERIK/hdeshev/w/nativescript-angular/tests/platforms/
android/build/intermediates/symbols/F0/debug
Successfully started process 'command '/opt/android-sdk-linux/build-tools/23.0.1/aa
pt''
Unknown source file :       Unable to add '/home/local/TELERIK/hdeshev/w/nativescri
pt-angular/tests/platforms/android/build/intermediates/assets/F0/debug/app/tns_modu
les/semver/semver.browser.js.gz': file already in archive (try '-u'?)

Unknown source file : ERROR: unable to process assets while packaging '/home/local/
TELERIK/hdeshev/w/nativescript-angular/tests/platforms/android/build/intermediates/
res/resources-F0-debug.ap_'
@rosen-vladimirov
Copy link
Contributor

npm link is not officially supported by us (CLI's executing npm install, so you should never get linked modules in your node_modules dir).
However the semver.js.gz issue had been raised several times, so having these steps to reproduce is a great help.
I firmly believe it's time to ignore all .gz files when preparing project for Android, as aapt fails to use them, what do you think?

@hdeshev
Copy link
Contributor Author

hdeshev commented Jun 6, 2016

npm link is not officially supported by us (CLI's executing npm install, so you should never get linked modules in your node_modules dir).

We are trying to support it. Anyway, I've seen the semver.js.gz error in cases that don't use npm links too.

I firmly believe it's time to ignore all .gz files when preparing project for Android, as aapt fails to use them

It shouldn't be a problem to do that, but it won't solve the original problem for cases where we end up with multiple files with the same names that break Android's AAPT tool. For the time being this happens with a gz file, but there's no guarantee it won't happen with a file having a different extension.

@slavchev
Copy link

slavchev commented Jul 6, 2016

The issue is with all "zip" file formats as aapt will treat these files as a "file system". In short, aapt will "attach" such file system and read the resources from there. In common scenarios like a module with mylib.js and mylib.js.gz which contains the former aapt will fail.

Additionally, the problem is somewhat obscure as tns --log trace will not help diagnosing it. Running gradlew build --debug from platform/android reveals the real issue.

As an immediate solution I would propose cli to filter all such files probably displaying a warning during prepare phase.

@ryc16
Copy link

ryc16 commented Sep 7, 2016

I got the same problem and can't move forward without get around this problem. Is this fixed? If not, is there any workaround at this point (even manual step) for me to keep working on the project rather totally dead here.

@hdeshev
Copy link
Contributor Author

hdeshev commented Sep 9, 2016

@ryc16 Yes, first delete your node_modules and platforms folders, then run a fresh tns install. Then, delete all .gz files below node_modules. On a Linux/Mac machine you could do:

find node_modules -iname '*.gz' -delete

You should now be able to npm run ... now.

@Plamen5kov
Copy link
Contributor

Should be resolved with: 0bc09ec

@tsonevn tsonevn added this to the 2.5.0 milestone Dec 5, 2016
@Plamen5kov
Copy link
Contributor

Plamen5kov commented Dec 8, 2016

closed in favor of: #1740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants