Adding package via npm to the project causes Error: Duplicate Resource on tns run

in utopian-io •  7 years ago  (edited)

Expected behavior

Project should successfully compile without any other modifications.

Actual behavior

tns will throw errors while compiling "Error: Duplicate Resource" and ultimately stop executing. This is due .js.map files being copied to platform and Android compiler doesn't differentiate between .js.map/.js.gz and .js files and treat them like they are equal.

How to reproduce

  1. Create new NativeScript project
  2. Add any package with .js.map files (Steem for example npm i --save steem)
  3. Build app: tns run android
  4. Watch for compile errors in console, right before Java throws compilation error there is merge assets error with Duplicate Resource message

Workaround:
After getting the error, go to platform/android and delete "duplicate" map/gz files from modules causing the issue.

  • Browser:
    N/A
  • Operating system:
    Windows 10 1709
  • Development software:
    Node v8.9.4
    JRE 8
    NativeScript v3.4.1
    tns-core 3.4.0
    tns-android 3.4.1

Recording Of The Bug

duplicate_res.png



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it is a duplicate. It is very similar to a contribution that was already accepted here.

Try using tns build android --release which might solve the problem

You can contact us on Discord.
[utopian-moderator]