NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

--env.uglify with {N}-ng 3.4.0 does not build #402

Closed Sharique-Hasan closed 6 years ago

Sharique-Hasan commented 6 years ago
Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
File:F:\code\projects\myapp\platforms\android\app\src\main\java\com\tns\gen\com\telerik\widget\autocomplete\AutoCompleteAdapter_frnal_ts_helpers_l58_c38__t.java Class:
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:68)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\code\projects\myapp\platforms\android\build-tools\android-static-binding-generator\build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe'' finished with non-zero exit value 1

This is the error I am getting while building with 3.4.0 using --env.uglify. Without it project gets build successfully.

P.S. I am not using RadAutoComplete component anywhere in my app.

sis0k0 commented 6 years ago

Hey @Sharique-Hasan, Could you please run the build command with reporting enabled?

tns build android --bundle  --env.uglify --env.report

This should generate a report directory that contains information about the webpack build. After that, can you please share that directory?

Sharique-Hasan commented 6 years ago

@sis0k0 This is report generated using --env.uglify and --env.report. And build failed with the same error as mentioned above. I have already cleaned the platform, hooks, node_modules multiple times. Didn't get success in any case.

I used --bundle --release flags

report.zip

Sharique-Hasan commented 6 years ago

My package.json

{
  "description": "My App",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.myapp.myapplication",
    "tns-android": {
      "version": "3.4.0"
    }
  },
  "scripts": {
    "lint": "tslint \"app/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "5.1.0",
    "@angular/common": "5.1.0",
    "@angular/compiler": "5.1.0",
    "@angular/core": "5.1.0",
    "@angular/forms": "5.1.0",
    "@angular/http": "5.1.0",
    "@angular/platform-browser": "5.1.0",
    "@angular/platform-browser-dynamic": "5.1.0",
    "@angular/router": "5.1.0",
    "@ngrx/effects": "4.1.1",
    "@ngrx/store": "4.1.1",
    "@ngx-translate/core": "9.0.2",
    "@ngx-translate/http-loader": "2.0.1",
    "@types/lodash": "4.14.92",
    "@types/node": "9.3.0",
    "lodash": "4.17.4",
    "moment": "2.20.1",
    "nativescript-angular": "5.1.0",
    "nativescript-appversion": "1.4.1",
    "nativescript-background-http": "3.1.0",
    "nativescript-camera": "3.2.1",
    "nativescript-facebook": "2.1.0",
    "nativescript-loading-indicator": "2.4.0",
    "nativescript-local-notifications": "2.0.2",
    "nativescript-localstorage": "1.1.5",
    "nativescript-mediafilepicker": "1.0.4",
    "nativescript-plugin-firebase": "^5.1.2",
    "nativescript-plugin-twitter": "2.0.7",
    "nativescript-pro-ui": "~3.3.0",
    "nativescript-sentry": "1.5.2",
    "nativescript-sms-inbox": "1.0.7",
    "nativescript-social-share": "1.5.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "1.4.6",
    "nativescript-videorecorder": "2.0.4",
    "nativescript-web-image-cache": "4.2.2",
    "reflect-metadata": "~0.1.10",
    "rxjs": "5.5.2",
    "tns-core-modules": "~3.4.0",
    "zone.js": "~0.8.18"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~5.1.0",
    "@ngtools/webpack": "~1.9.1",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "codelyzer": "~4.0.2",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "~1.3.5",
    "nativescript-dev-typescript": "~0.6.0",
    "nativescript-dev-webpack": "~0.9.0",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "sass-loader": "~6.0.6",
    "tslint": "~5.8.0",
    "typescript": "^2.6.2",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.9.1",
    "webpack-sources": "~1.1.0"
  }
}
Sharique-Hasan commented 6 years ago

Updating nativescript-pro-ui to @next version fixed it

ButterMeWaffle commented 6 years ago

@Sharique-Hasan any chance you could post the exact version number for the pro-ui? I am getting the exact same error as you even after using @next for the plugin

wendt88 commented 6 years ago

same here

NickIliev commented 6 years ago

@SamuelReeder @wendt88 can you guys please share more details on your projects (package.json)

wendt88 commented 6 years ago

shure:

"dependencies": {
    "@angular/animations": "~5.2.0",
    "@angular/common": "~5.2.0",
    "@angular/compiler": "~5.2.0",
    "@angular/core": "~5.2.0",
    "@angular/forms": "~5.2.0",
    "@angular/http": "~5.2.0",
    "@angular/platform-browser": "~5.2.0",
    "@angular/platform-browser-dynamic": "~5.2.0",
    "@angular/router": "~5.2.0",
    "nativescript-angular": "~5.2.0",
    "nativescript-appavailability": "^1.3.1",
    "nativescript-drop-down": "^3.2.0",
    "nativescript-i18n": "^0.2.4",
    "nativescript-insomnia": "^1.2.1",
    "nativescript-intl": "^3.0.0",
    "nativescript-orientation": "^2.2.0",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-pulltorefresh": "^2.1.0",
    "reflect-metadata": "^0.1.12",
    "rxjs": "~5.5.2",
    "tns-core-modules": "^3.4.0",
    "zone.js": "^0.8.20"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~5.2.0",
    "@ngtools/webpack": "^1.8.6",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "^0.28.9",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "^1.3.5",
    "nativescript-dev-typescript": "^0.6.0",
    "nativescript-dev-webpack": "^0.9.1",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "sass-loader": "~6.0.6",
    "typescript": "^2.6.2",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.9.1",
    "webpack-sources": "~1.1.0"
  }

tns version is 3.4.1

dali-gharbi commented 6 years ago

i confirm having the same issue :

Running full build
Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
File:C:\Users\mhdali\Desktop\Projects\Perfony\platforms\android\app\src\main\java\com\tns\gen\com\telerik\widget\autocomplete\AutoCompleteAdapter_frnal_ts_helpers_l58_c38__t.java Class:
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:68)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\mhdali\Desktop\Projects\Perfony\platforms\android\build-tools\android-static-binding-generator\build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_144\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 18s
Unable to apply changes on device: 4200f3d99b7323ed. Error is: Command gradlew.bat failed with exit code 1.
wendt88 commented 6 years ago

@NickIliev any news how to solve this problem?

dali-gharbi commented 6 years ago

actually i did found an unused import of RADAutoComplete in my project, after deleting the import all worked fine and i am building with all --env params.

wendt88 commented 6 years ago

I tried a bit to remove some packages and found the problem in nativescript-pulltorefresh-plugin:

import { PullToRefresh } from "nativescript-pulltorefresh";
registerElement("PullToRefresh", () => PullToRefresh);

without the registerElement the uglify build works fine. But I don´t know why and how to fix

wendt88 commented 6 years ago

adding "TNS_SwipeRefreshListener" to nsWebpack.uglifyMangleExcludes-array in webpack.config solved the problem for me