NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
524 stars 135 forks source link

Huge pain migrating to {N} 3.4 with WebPack #911

Closed TheOnlyMatt closed 6 years ago

TheOnlyMatt commented 6 years ago

Despite the slowness of the looong launch time and the slow navigation experiencing on the version 3.3, I decided to update to the latest version of Nativescript, embedding the famous Webpack, which apparently offers greats performance improvements.

To do so, I followed each one of the instructions here. This led me to have a new version of the application, getting webpack (which I didn't succeeded to get working on the previous version) and {N} 3.4. As I am typing on my keyboard the so-used command to run the app on my device, I am full of hopes that the Nativescript Developer team found a way to get rid of all the problems that was happening before, when trying to integrate WebPack to an existing project.

Oh no I am in front of a big stack of errors about relative paths; thus I refactor all of my components' paths to stop seeing all these errors.

Now everything is clean, the app builds without any problem, it is now installed on my device. My application is now opening, that's wonderful it works like charm now, and oh wait, it just crashed ... Perhaps just a bug, I try to restart the app, and it crash again ...

All my hopes fly away, I facing the same problems that with the previous nativescript version.

I am not going to let down so easily, so I try to get it running with all the optimized setting options I have found : tns run android --bundle --env.aot --env.snapshot --env.uglify --env.report Doing so the app is not even building, and shows other errors.

I have currently been struggling against an incalculable number of errors coming from everywhere, but I feel like stuck in quicksand. Every time I solve one, another is popping. For example, I had errors about SDK licenses, about aot files excluded from tsconfig, about plugin dependencies, but nothing seems to be the final solution. So I am here to request for your help because I am getting desperate getting my app running with all the benefits from webpack ...

Here is the latest error I am facing :

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:/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/java/com/tns/gen/java/lang/Object_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 '/Users/me/Documents/nativescript_apps/myapp/platforms/android/build-tools/android-static-binding-generator/build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

As before, if I launch tns run android, the app builds fine, but crashes on startup, and if I run tns run android --bundle --env.aot --env.snapshot --env.uglify --env.report I get this error.

I will appreciate any kind of help !

petekanev commented 6 years ago

Hey @TheOnlyMatt, I'm sorry to hear that you are struggling to get up and running with WebPack in your Android NativeScript application.

It would help us greatly if you could provide answer the following questions:

If possible, please provide a minimal sample that errors out similarly to what you are experiencing, so that we can have a look at the problem on our end.

Thanks!

TheOnlyMatt commented 6 years ago

Hi, thank you for paying attention to my issue.

- Here is my jsFilesParameter file :

/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/_embeddedscript.js /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/bundle.js /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/starter.js /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/tns-java-classes.js /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/vendor.js



I am going to try updating a sample project to the version 3.4, and tell you if I experience the same problems
petekanev commented 6 years ago

@TheOnlyMatt one more thing, do you see any errors from the webpack and snapshot runs? What is the entire build output from the moment you input the tns run android --bundle command?

Have you tried webpacking and snapshotting, thus isolating the problem to be with the snapshot process, if there is one at all. You might have to remove the platform beforehand to ensure there are no previous artifacts messing with your bundle this time around.

TheOnlyMatt commented 6 years ago

When tns run android --bundle, the app builds and crashes on startup on the device, the same happens when tns run android --bundle --env.snapshot. The only error is :

ActivityManager: Start proc 15940:com.me.myapp/u0a353 for activity com.me.myapp/com.tns.NativeScriptActivity
ActivityManager: Process com.me.myapp (pid 15940) has died
ActivityManager: SVC-handleAppDiedLocked: app = ProcessRecord{42edbe5 15940:com.me.myapp/u0a353}, app.pid = 15940
ActivityManager: cleanUpApplicationRecord -- 15940

But when tns run android --bundle --env.snapshot --env.uglify the error on build occurs. Here is the complete output :

^Cme-imac01:myapp me tns run android --bundle --env.snapshot --env.uglify 
Searching for devices...
Executing before-liveSync hook from /Users/me/Documents/nativescript_apps/myapp/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-prepare hook from /Users/me/Documents/nativescript_apps/myapp/hooks/before-prepare/nativescript-dev-typescript.js
Hook skipped because either bundling or livesync is in progress.
Preparing project...
Executing before-prepareJSApp hook from /Users/me/Documents/nativescript_apps/myapp/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Running webpack for Android...
Project root: /Users/me/Documents/nativescript_apps/myapp
Snapshots build directory: /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/snapshot-build/build
 95% emitting                                                                           
 Snapshotting bundle at /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/vendor.js
Running snapshot generation with the following arguments: 
{
        "inputFile": "/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/vendor.js",
        "preprocessedInputFile": "/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/_embedded_script_.js",
        "targetArchs": [
                "arm",
                "arm64",
                "ia32"
        ],
        "useLibs": false,
        "tnsJavaClassesPath": "/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/tns-java-classes.js"
}
Snapshot tools path: /var/folders/mm/wlcynsns14n3nljyjwmstr2r0000gn/T/snapshot-tools
Webpack compilation complete.
***** Generating snapshot for armeabi-v7a *****
***** Generating snapshot for arm64-v8a *****
***** Generating snapshot for x86 *****
Loading script for embedding: /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/_embedded_script_.js
Executing custom snapshot script <embedded> took 266.363 ms
Deserialization will reserve:
   4868040 bytes per isolate
   1240296 bytes per context #0
Snapshot blob consists of:
   4426660 bytes for startup
    621572 bytes for context #0
Creating snapshot took 514.229 ms

Loading script for embedding: /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/_embedded_script_.js
Executing custom snapshot script <embedded> took 1541.216 ms
Deserialization will reserve:
   4996432 bytes per isolate
   1240220 bytes per context #0
Snapshot blob consists of:
   4539564 bytes for startup
    622700 bytes for context #0
Creating snapshot took 1778.426 ms

Loading script for embedding: /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/assets/app/_embedded_script_.js
Executing custom snapshot script <embedded> took 1795.293 ms
Deserialization will reserve:
   6291536 bytes per isolate
   2479800 bytes per context #0
Snapshot blob consists of:
   4888452 bytes for startup
    831604 bytes for context #0
Creating snapshot took 2020.447 ms

***** Finished generating snapshots. *****
Snapshots build finished succesfully!
Successfully generated snapshots!                                                                                                                                                         Hash: b6f36e59180a5ccbdf9b
Version: webpack 3.8.1
Time: 30851ms
                                                                                            Asset       Size  Chunks                    Chunk Names
                            App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png    16.1 kB          [emitted]         
                                                                                        bundle.js     866 kB       0  [emitted]  [big]  bundle
                                                                                        vendor.js    1.32 MB       2  [emitted]  [big]  vendor
                                                        App_Resources/Android/AndroidManifest.xml     2.2 kB          [emitted]         
                                                                 App_Resources/Android/app.gradle  351 bytes          [emitted]         
                                               App_Resources/Android/drawable-hdpi/background.png    2.34 kB          [emitted]         
                                                     App_Resources/Android/drawable-hdpi/icon.png    95.3 kB          [emitted]         
                                                     App_Resources/Android/drawable-hdpi/menu.png  291 bytes          [emitted]         
                                               App_Resources/Android/drawable-ldpi/background.png  845 bytes          [emitted]         
                                                     App_Resources/Android/drawable-ldpi/icon.png    20.9 kB          [emitted]         
                                                     App_Resources/Android/drawable-ldpi/logo.png    6.63 kB          [emitted]         
                                                     App_Resources/Android/drawable-hdpi/logo.png    94.4 kB          [emitted]         
                                                     App_Resources/Android/drawable-ldpi/menu.png  213 bytes          [emitted]         
                                               App_Resources/Android/drawable-mdpi/background.png     1.3 kB          [emitted]         
                                                     App_Resources/Android/drawable-mdpi/icon.png      38 kB          [emitted]         
                                                     App_Resources/Android/drawable-mdpi/logo.png    35.7 kB          [emitted]         
                                                     App_Resources/Android/drawable-mdpi/menu.png  235 bytes          [emitted]         
                                           App_Resources/Android/drawable-nodpi/splash_screen.xml  304 bytes          [emitted]         
                                              App_Resources/Android/drawable-xhdpi/background.png    3.79 kB          [emitted]         
                                                    App_Resources/Android/drawable-xhdpi/menu.png  297 bytes          [emitted]         
                                             App_Resources/Android/drawable-xxhdpi/background.png    7.37 kB          [emitted]         
                                                    App_Resources/Android/drawable-xhdpi/icon.png     178 kB          [emitted]         
                                                    App_Resources/Android/drawable-xhdpi/logo.png     321 kB          [emitted]  [big]  
                                                   App_Resources/Android/drawable-xxhdpi/menu.png  378 bytes          [emitted]         
                                            App_Resources/Android/drawable-xxxhdpi/background.png    13.8 kB          [emitted]         
                                                   App_Resources/Android/drawable-xxhdpi/icon.png     472 kB          [emitted]  [big]  
                                                   App_Resources/Android/drawable-xxhdpi/logo.png     811 kB          [emitted]  [big]  
                                                  App_Resources/Android/drawable-xxxhdpi/menu.png  466 bytes          [emitted]         
                                                      App_Resources/Android/values-v21/colors.xml  104 bytes          [emitted]         
                                                       App_Resources/Android/google-services.json    1.04 kB          [emitted]         
                                                      App_Resources/Android/values-v21/styles.xml    1.07 kB          [emitted]         
                                                          App_Resources/Android/values/colors.xml  237 bytes          [emitted]         
                                    App_Resources/Android/values/nativescript_google_maps_api.xml  164 bytes          [emitted]         
                                                         App_Resources/Android/values/strings.xml  127 bytes          [emitted]         
                                                          App_Resources/Android/values/styles.xml    1.77 kB          [emitted]         
                               App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json    1.81 kB          [emitted]         
                                                  App_Resources/Android/drawable-xxxhdpi/icon.png     857 kB          [emitted]  [big]  
                                App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-120.png    8.63 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20.png  742 bytes          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png    1.82 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png     3.1 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png    1.14 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png    2.83 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png    5.04 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png    1.82 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png    4.59 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png    8.63 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png    2.29 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png    6.67 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@3x.png    12.5 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png    2.78 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png    7.88 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@3x.png    16.9 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60.png     3.1 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png    8.63 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png      18 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png    4.05 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png    11.5 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@3x.png      27 kB          [emitted]         
                                 App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png    4.26 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png    12.7 kB          [emitted]         
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@3x.png    28.7 kB          [emitted]         
                                                                              tns-java-classes.js  383 bytes       1  [emitted]         tns-java-classes
                              App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-Small.png    1.14 kB          [emitted]         
                           App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-Small@2x.png    2.83 kB          [emitted]         
                           App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-Small@3x.png    5.04 kB          [emitted]         
                                    App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon.png    2.78 kB          [emitted]         
                           App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork.png     178 kB          [emitted]         
                                                  App_Resources/iOS/Assets.xcassets/Contents.json   62 bytes          [emitted]         
                    App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png     142 kB          [emitted]         
                    App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png     147 kB          [emitted]         
                               App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png     857 kB          [emitted]  [big]  
                    App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-812h@3x.png     450 kB          [emitted]  [big]  
                  App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png     108 kB          [emitted]         
                                                  App_Resources/Android/drawable-xxxhdpi/logo.png    1.33 MB          [emitted]  [big]  
               App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png     586 kB          [emitted]  [big]  
                   App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png     341 kB          [emitted]  [big]  
               App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png     911 kB          [emitted]  [big]  
                            App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png    53.2 kB          [emitted]         
                         App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png     247 kB          [emitted]         
                    App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png    1.52 MB          [emitted]  [big]  
   App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png    3.79 kB          [emitted]         
App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png    13.8 kB          [emitted]         
App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@3x.png    27.5 kB          [emitted]         
                  App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Landscape-812h@3x.png     461 kB          [emitted]  [big]  
                        App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png     857 kB          [emitted]  [big]  
                                                         App_Resources/iOS/navigation/menu@3x.png  378 bytes          [emitted]         
                                                         App_Resources/iOS/navigation/menu@2x.png  297 bytes          [emitted]         
                                                            App_Resources/iOS/navigation/menu.png  235 bytes          [emitted]         
                                                        App_Resources/iOS/LaunchScreen.storyboard    3.93 kB          [emitted]         
                                                                     App_Resources/iOS/Info.plist    2.12 kB          [emitted]         
                                                            App_Resources/iOS/command_ios_release   85 bytes          [emitted]         
                                                                 App_Resources/iOS/build.xcconfig  492 bytes          [emitted]         
                App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png     1.4 MB          [emitted]  [big]  
           App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png    39.8 kB          [emitted]         
        App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png     341 kB          [emitted]  [big]  
                                                                            fonts/FontAwesome.ttf     166 kB          [emitted]         
                                                                          fonts/Raleway-Light.ttf     182 kB          [emitted]         
                                                                         fonts/Raleway-Medium.ttf     179 kB          [emitted]         
                                                                       fonts/Raleway-SemiBold.ttf     180 kB          [emitted]         
                                                                          images/event-border.jpg    11.3 kB          [emitted]         
                                                                                 images/apple.jpg     277 kB          [emitted]  [big]  
                                                                     images/arrow-blue-circle.png    1.68 kB          [emitted]         
                                                                            images/hotte-noel.png    2.26 kB          [emitted]         
                                                                            images/deals-icon.png    3.46 kB          [emitted]         
                                                                        images/icon-link-grey.png    18.1 kB          [emitted]         
                                                                              images/icon-pdf.png    15.9 kB          [emitted]         
                                                                            images/clock-icon.png    6.98 kB          [emitted]         
                                                                             images/icon-link.png    15.2 kB          [emitted]         
                                                                         images/logo-ce-white.png    40.9 kB          [emitted]         
                                                                            images/icon-video.png    15.1 kB          [emitted]         
                                                                      images/logo-ce-white-xl.png     119 kB          [emitted]         
                                                                             images/more-icon.png    1.97 kB          [emitted]         
                                                                             images/news-icon.png    2.51 kB          [emitted]         
                                                                          images/position-pin.png    4.61 kB          [emitted]         
                                                                           images/menu-burger.png    1.36 kB          [emitted]         
                                                                            images/phone-icon.png    4.93 kB          [emitted]         
                                                                     images/simple-arrow-grey.png    16.8 kB          [emitted]         
                                                                    images/simple-arrow-white.png  438 bytes          [emitted]         
                                                                           images/slider-next.png    2.69 kB          [emitted]         
                                                                           images/slider-prev.png    2.67 kB          [emitted]         
                                                                      images/white-left-arrow.png    1.18 kB          [emitted]         
                                                                             images/text-icon.png    1.62 kB          [emitted]         
                                                                                     package.json  222 bytes          [emitted]         
                                                                                       starter.js   39 bytes          [emitted]         
  [18] ./providers/dispatcher.ts 5.68 kB {0} [built]
  [23] ./providers/page-data.service.ts 452 bytes {0} [built]
  [33] ./providers/request-sender.service.ts 3.48 kB {0} [built]
  [40] ./providers/loader.ts 949 bytes {0} [built]
  [44] ./providers/rubrique-hierarchy.service.ts 540 bytes {0} [built]
 [105] ./providers/menu-data.ts 2.4 kB {0} [built]
 [109] ./shared/shared.module.ts 1.71 kB {0} [built]
 [112] ./package.json 179 bytes {2} [optional] [built]
 [225] ./main.ts 1.15 kB {0} [built]
 [294] ./app.module.ts 3.4 kB {0} [built]
 [386] ./rubrique/rubrique.module.ts 2.65 kB {0} [built]
 [413] ./vendor.ts 634 bytes {2} [built]
 [414] . nonrecursive ^\.\/app\.(css|scss|less|sass)$ 174 bytes {2} [built]
 [417] ./vendor-platform.ts 406 bytes {2} [built]
 [418] ../platforms/android/app/snapshot-build/tns-java-classes.js 59 bytes {1} [built]
    + 404 hidden modules
Project successfully prepared (Android)
Executing after-prepare hook from /Users/me/Documents/nativescript_apps/myapp/hooks/after-prepare/nativescript-dev-webpack.js
Building project...
Gradle build...
         + applying user-defined configuration from /Users/me/Documents/nativescript_apps/myapp/app/App_Resources/Android/app.gradle
         + creating include.gradle for plugin /Users/me/Documents/nativescript_apps/myapp/platforms/node_modules/nativescript-calendar
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-carousel/platforms/android/include.gradle
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-effects/platforms/android/include.gradle
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-geolocation/platforms/android/include.gradle
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-google-maps-sdk/platforms/android/include.gradle
         + creating include.gradle for plugin /Users/me/Documents/nativescript_apps/myapp/platforms/node_modules/nativescript-phone
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/include.gradle
         + add include.gradle from /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-ripple/platforms/android/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-calendar/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-carousel/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-effects/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-geolocation/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-google-maps-sdk/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-phone/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-pro-ui/include.gradle
         + applying plugin configuration from /Users/me/Documents/nativescript_apps/myapp/platforms/android/app/build/configurations/nativescript-ripple/include.gradle
         + adding nativescript runtime package dependency: nativescript-optimized
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Chart-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Common-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Data-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Feedback-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Gauges-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Input-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/List-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/nativescript-pro-ui/platforms/android/Primitives-2017.1.1221-dev-release.aar
         + adding aar plugin dependency: /Users/me/Documents/nativescript_apps/myapp/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
false
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:/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/java/com/tns/gen/java/lang/Object_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 '/Users/me/Documents/nativescript_apps/myapp/platforms/android/build-tools/android-static-binding-generator/build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java'' 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 41s
Unable to apply changes on device: 0123456789ABCDEF. Error is: Command ./gradlew failed with exit code 1.
Executing after-watch hook from /Users/me/Documents/nativescript_apps/myapp/hooks/after-watch/nativescript-dev-typescript.js

I guess the problem is from the uglyfy :/

And I removed/added the platforms several times before when I was trying to solve this, so I don't think it will change anything. (I forgot to mention that this is an Angular project)

TheOnlyMatt commented 6 years ago

Okay so I updated my sample project, and I get the same error than I have earlier solved on my real project :

Searching for devices...
Executing before-liveSync hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-prepare hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/before-prepare/nativescript-dev-typescript.js
Hook skipped because either bundling or livesync is in progress.
Preparing project...
Executing before-prepareJSApp hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Running webpack for Android...

/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:88
        const config = ngtools_api_1.readConfiguration(this._tsConfigPath);
                                     ^
TypeError: ngtools_api_1.readConfiguration is not a function
    at NativeScriptAngularCompilerPlugin._setupOptions (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:88:38)
    at new AngularCompilerPlugin (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:43:14)
    at new NativeScriptAngularCompilerPlugin (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.ts:36:9)
    at module.exports.env (/Users/me/Documents/nativescript_apps/ngGoogleMap/webpack.config.js:102:13)
    at handleFunction (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/lib/prepareOptions.js:26:13)
    at prepareOptions (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/lib/prepareOptions.js:11:13)
    at requireConfig (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/bin/convert-argv.js:98:14)
    at /Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/bin/convert-argv.js:104:17
    at Array.forEach (<anonymous>)
    at module.exports (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/bin/convert-argv.js:102:15)
    at yargs.parse (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/bin/webpack.js:171:41)
    at Object.Yargs.self.parse (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/node_modules/yargs/yargs.js:533:18)
    at Object.<anonymous> (/Users/me/Documents/nativescript_apps/ngGoogleMap/node_modules/webpack/bin/webpack.js:152:7)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
Unable to apply changes on device: 0123456789ABCDEF. Error is: Executing webpack failed with exit code 1..
Executing after-watch hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/after-watch/nativescript-dev-sass.js
Executing after-watch hook from /Users/me/Documents/nativescript_apps/ngGoogleMap/hooks/after-watch/nativescript-dev-typescript.js

Right now I don't remember how I solved it so I am going to search again and tell you what I did to clear up this error.

TheOnlyMatt commented 6 years ago

To solve this previous error, I have done twice the instructions indicated in this tuto , then I refactored my components' paths. So this error is gone, and the next showing is :

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK Build Tools revision (24.0.0) is too low for project ':app'. Minimum required is 25.0.0

Changing the dependencies from 2.3.3 to 3.0.1 in the android/build.gradle file seems to do the trick

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }

The following issue is :

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.

I had to execute these instructions to have my sdk licenses accepted :

Still the last command was not executed, it kept telling me that I didn't have accepted the license agreements, even if the sdkmanager --licenses was telling me that everything was accepted.

Now here is the failure I have got (still on my sample projects; errors are the same than on my real projects) :

Build file '/Users/me/Documents/nativescript_apps/ngGoogleMap/platforms/android/app/build.gradle' line: 64

* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'outputFile' for task ':app:packageF0F1F2Debug' of type com.android.build.gradle.tasks.PackageApplication.
petekanev commented 6 years ago

@TheOnlyMatt I am not sure I've seen that error in a long time, and when I have, it's usually only on CI without interactive consoles. Maybe the project is too old? And I'd assume you have installed the build tools through the Android SDK manager, correct?

TheOnlyMatt commented 6 years ago

No I don't think it is about the age of the projects. I created my sample maybe two or three months ago, and for my real project was in June 2017.

On android studio, the sdk manager tells me that the Android SDK build-tool is installed (doesn't tell me there is any update)

TheOnlyMatt commented 6 years ago

I come back because my case has a bit evolved. I finally succeeded to get my sample app working, after have tried many changes in app/build.gradle, I removed and added the platform and my sample app could run again on devices.

I tried to do the same on my real project, but I still got the first error described

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:/Users/me/Documents/nativescript_apps/myapp/platforms/android/app/src/main/java/com/tns/gen/java/lang/Object_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 '/Users/me/Documents/nativescript_apps/myapp/platforms/android/build-tools/android-static-binding-generator/build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

PS : I have an error when running npm i -g nativescript

> nativescript@3.4.0 preuninstall /Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript
> node preuninstall.js

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: abbrev@1.1.0 (node_modules/nativescript/node_modules/fsevents/node_modules/abbrev):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript/node_modules/fsevents/node_modules/abbrev' -> '/Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript/node_modules/fsevents/node_modules/.abbrev.DELETE'

npm ERR! path /Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript/node_modules/fsevents/node_modules/ansi-regex
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript/node_modules/fsevents/node_modules/ansi-regex' -> '/Users/me/.nvm/versions/node/v9.3.0/lib/node_modules/nativescript/node_modules/fsevents/node_modules/.ansi-regex.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2018-01-04T10_25_51_914Z-debug.log

I don't know if it is related, but I must run uninstall script then install to update Nativescript

jibon57 commented 6 years ago

I am facing exactly same problem using this template: https://github.com/NativeScript/template-drawer-navigation-ng I did fresh installation & followed: https://www.nativescript.org/blog/nativescript-webpack-0.9.0-what-changed-and-how-to-upgrade

tns run android --bundle
Searching for devices...
Executing before-liveSync hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-prepare hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/before-prepare/nativescript-dev-typescript.js
Hook skipped because either bundling or livesync is in progress.
Preparing project...
Executing before-prepareJSApp hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Running webpack for Android...

/Users/jibon/Documents/My_Work/rsdemo/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:88
        const config = ngtools_api_1.readConfiguration(this._tsConfigPath);
                                     ^
TypeError: ngtools_api_1.readConfiguration is not a function
    at NativeScriptAngularCompilerPlugin._setupOptions (/Users/jibon/Documents/My_Work/rsdemo/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:88:38)
    at NativeScriptAngularCompilerPlugin.AngularCompilerPlugin (/Users/jibon/Documents/My_Work/rsdemo/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:43:14)
    at NativeScriptAngularCompilerPlugin (/Users/jibon/Documents/My_Work/rsdemo/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.ts:36:9)
    at module.exports.env (/Users/jibon/Documents/My_Work/rsdemo/webpack.config.js:102:13)
    at handleFunction (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/lib/prepareOptions.js:26:13)
    at prepareOptions (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/lib/prepareOptions.js:11:13)
    at requireConfig (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/bin/convert-argv.js:98:14)
    at /Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/bin/convert-argv.js:104:17
    at Array.forEach (native)
    at module.exports (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/bin/convert-argv.js:102:15)
    at yargs.parse (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/bin/webpack.js:171:41)
    at Object.Yargs.self.parse (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/node_modules/yargs/yargs.js:533:18)
    at Object.<anonymous> (/Users/jibon/Documents/My_Work/rsdemo/node_modules/webpack/bin/webpack.js:152:7)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
Unable to apply changes on device: 192.168.56.101:5555. Error is: Executing webpack failed with exit code 1..
Executing after-watch hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/after-watch/nativescript-dev-sass.js
Executing after-watch hook from /Users/jibon/Documents/My_Work/rsdemo/hooks/after-watch/nativescript-dev-typescript.js
petekanev commented 6 years ago

@jibon57 according to our QAs the template-drawer-navigation-ng isn't in a webpackable state yet, but is pending a proper webpackable release later this week.

cc @dtopuzov

TheOnlyMatt commented 6 years ago

Ok thank you, it might be the same problem on my side, I am also using the drawer template.

petekanev commented 6 years ago

@TheOnlyMatt we apologize if that is causing you problems with snapshots, we'll make sure temporary incompatibilities with any of the NativeScript components are made more visible in the future.

NickIliev commented 6 years ago

@TheOnlyMatt @jibon57 the drawer template is now updated to use the latest nativescript-dev-webpack and nativescript-angular + all related dependencies and is now Webpack compatible

jibon57 commented 6 years ago

@NickIliev, getting error like:

+-- UNMET PEER DEPENDENCY typescript@~2.4.2

Still need to follow: https://www.nativescript.org/blog/nativescript-webpack-0.9.0-what-changed-and-how-to-upgrade

NickIliev commented 6 years ago

@jibon57 I am notable to reproduce the issue Creating a test project and bundling it with the following commands:

tns create testApp --template tns-template-drawer-navigation-ng
cd testApp
tns run android --bundle

And the project is bundled with Webpack and deployed & started successfully.

TheOnlyMatt commented 6 years ago

Hi NickIliev ! I merged my package.json with the one from the template-drawer, here is what I have :

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "my.app.id",
    "tns-ios": {
      "version": "3.4.0"
    },
    "tns-android": {
      "version": "3.4.0"
    }
  },
  "scripts": {
    "preinstall": "node tools/preinstall.js",
    "postinstall": "node tools/postinstall.js"
  },
  "android": {
    "v8Flags": "--expose_gc"
  },
  "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",
    "nativescript-angular": "~5.1.0",
    "nativescript-pro-ui": "~3.3.0",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~5.5.5",
    "tns-core-modules": "~3.4.0",
    "zone.js": "~0.8.18",
    "html-entities": "^1.2.1",
    "nativescript-accordion": "^5.0.3",
    "nativescript-calendar": "^1.2.2",
    "nativescript-carousel": "^3.1.1",
    "nativescript-directions": "^1.1.0",
    "nativescript-drop-down": "^3.2.0",
    "nativescript-effects": "^1.0.0",
    "nativescript-email": "^1.5.1",
    "nativescript-geolocation": "^4.2.0",
    "nativescript-google-maps-sdk": "^2.4.3",
    "nativescript-iqkeyboardmanager": "^1.1.0",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-phone": "^1.3.1",
    "nativescript-pulltorefresh": "^2.0.2",
    "nativescript-ripple": "^2.0.0"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~5.0.0",
    "@ngtools/webpack": "~1.8.2",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "codelyzer": "~4.0.2",
    "nativescript-dev-sass": "~1.3.5",
    "nativescript-dev-typescript": "~0.6.0",
    "nativescript-dev-webpack": "~0.9.1",
    "tslint": "~5.8.0",
    "typescript": "~2.4.2",
    "copy-webpack-plugin": "~4.0.1",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-worker-loader": "~0.8.1",
    "node-sass": "4.5.3",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.1.0",
    "tns-platform-declarations": "^3.3.0",
    "webpack": "~3.8.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "sass-loader": "~6.0.6"
  }
}

Now I am facing a webpack error on build : Unable to apply changes on device: 0123456789ABCDEF. Error is: Executing webpack failed with exit code 2.

petekanev commented 6 years ago

@TheOnlyMatt what's the webpack process output?

TheOnlyMatt commented 6 years ago

nativescript-java-error.txt My bad, for the exit code 2 when I scrolled up I saw it was some accessors missing in my code. I corrected all of it and now I am facing the exact same issue than in the first comment. I send the file with the complete error log in attachment.

petekanev commented 6 years ago

@TheOnlyMatt the error is indicative of several instances of the core modules being parsed by our bindings (java class) generator. I'll have to ask you again to share the contents of ns-project\platforms\android\build-tools\android-static-binding-generator\jsFilesParameters.txt and ns-project\platforms\android\build-tools\android-static-binding-generator\bindings.txt again so I can analyze them further.

And, does the build go through without passing the uglify option?

TheOnlyMatt commented 6 years ago

Here are the files bindings.txt jsFilesParameters.txt

Yes, the problem is still from the uglify option. Does it really worth the improvements to investigate further more for this problem ?

petekanev commented 6 years ago

@TheOnlyMatt I spotted the two classes that have been omitted during the uglification, and as a result we treat them as the same class. One class implements the android.widget.AdapterView.OnItemSelectedListener interface, and the other android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener. The error could be in the core modules, or the pro-ui plugin. I am currently investigating and will update you with anything new I learn.

In other news, I am happy to say that we are working on a fix which should drastically reduce such scenarios, and webpack+uglify should be a lot smoother. - https://github.com/NativeScript/android-runtime/pull/923

TheOnlyMatt commented 6 years ago

Ok nice to hear that ! Thanks for your support, I am waiting for your updates :)

petekanev commented 6 years ago

Found the offending plugins. One is pulltorefresh - https://github.com/bradmartin/nativescript-pulltorefresh, and the other appears to be https://github.com/PeterStaev/NativeScript-Drop-Down

They don't appear to be uglify-ready. Until we are ready to push the fix to production, the authors will need to provide additional webpack configuration to allow their plugins to work seamlessly with webpack+uglify builds.

cc @bradmartin @PeterStaev

TheOnlyMatt commented 6 years ago

Ok I guess I should have read more carefully the plugins docs ...

So I pasted their uglify code in the webpack config file

//This first statement was there before my modifications
 if (uglify) {
        config.plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));

        // Work around an Android issue by setting compress = false
        const compress = platform !== "android";
        config.plugins.push(new webpack.optimize.UglifyJsPlugin({
            mangle: { except: nsWebpack.uglifyMangleExcludes },
            compress,
        }));
    }
    if (env.uglify) {
        config.plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));

        const mangle =  {
            except: [
                ...nsWebpack.uglifyMangleExcludes,
            "TNS_SwipeRefreshListener"
        ]
        };

        // Work around an Android issue by setting compress = false
        const compress = platform !== "android";

        config.plugins.push(new webpack.optimize.UglifyJsPlugin({
            mangle,
            compress,
        }));
    }
    if (env.uglify) {
        config.plugins.push(new webpack.LoaderOptionsPlugin({
            minimize: true
        }));

        //Work around an Android issue by setting compress = false
        var compress = platform !== "android";
        config.plugins.push(new webpack.optimize.UglifyJsPlugin({
            mangle: {
                except: nsWebpack.uglifyMangleExcludes.concat(dropDownMangleExcludes),
            },
            compress: compress,
        }));
    }

Even with these changes I still got the Java error, but I suspect the different pushes to erase each other, so I am currently trying to merge the three statements into one to check if it's better.

petekanev commented 6 years ago

@TheOnlyMatt did you purge the platforms/android before-hand? I am suspecting there might be left overs from the previous parsing of the webpack bundle.

TheOnlyMatt commented 6 years ago

Nope I didn't removed the platform before, but that finally works !! 🎉 😃

After merging the three statements, I ended up with this, which works incredibly well :

if (env.uglify) {
        nsWebpack.uglifyMangleExcludes = nsWebpack.uglifyMangleExcludes.concat(dropDownMangleExcludes)

        const mangle =  {
            except: [
                ...nsWebpack.uglifyMangleExcludes,
                "TNS_SwipeRefreshListener"
            ]
        };

        // Work around an Android issue by setting compress = false
        const compress = platform !== "android";

        config.plugins.push(new webpack.optimize.UglifyJsPlugin({
            mangle,
            compress,
        }));
    }

The command tns run android --bundle --env.snapshot --env.uglify --env.aot reduced my app launching time from about 20s to 3s, which such of an amazing improvement ! The only thing is that now my app design and links are broken, but I already experienced this due to the snapshot, so I think it will be ok to fix this. Do you advise me anyway to do a platform remove/add to clear ?

petekanev commented 6 years ago

@TheOnlyMatt I don't usually advise people to remove platforms/android, but I thought it might have something to do with old resources.

Feel free to close the issue if you believe the original issue has been resolved!

TheOnlyMatt commented 6 years ago

Huh just one last thing before I close the issue, I thought my design and navigation issues were due to an error which was showing, but after have removed the cause of the error, the issue is still there. I have a login page, strangely enough, there is no design or navigation problem on this one. After have passed the identification phase, on the main page, I cannot navigate anywhere else, and some design elements are broken.

When the app is running, there are no error. I tested different cases, and actually this only occurs with the aot option.

Do you have any idea why this happens ?

petekanev commented 6 years ago

@TheOnlyMatt It would be best to open a separate issue at https://github.com/NativeScript/nativescript-angular/issues or https://github.com/NativeScript/NativeScript/issues. Describe your issue in details there, and see if you can provide a debuggable application for the team to have a look at.

alexma01 commented 6 years ago

Hi @TheOnlyMatt , i have same problem (JAVA io.Exception) but when i start tns build android --bundle. Any idea?


  "tns-android": {
      "version": "4.1.0-2018.4.27.2"
    }```

`
  "dependencies": {
     "@angular/animations": "~5.0.0",
     "@angular/common": "~5.0.0",
     "@angular/compiler": "~5.0.0",
     "@angular/core": "~5.0.0",
     "@angular/forms": "~5.0.0",
     "@angular/http": "~5.0.0",
     "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/router": "~5.0.0",
    "angular2-jwt": "^0.2.3",
    "angular2-moment": "^1.8.0",
    "base-64": "^0.1.0",
    "buffer": "^5.0.8",
    "file-system": "^2.2.2",
    "http": "0.0.0",
    "moment-timezone": "^0.5.14",
    "nativescript-angular": "^5.0.0",
    "nativescript-background-http": "^3.1.0",
    "nativescript-camera": "^4.0.2",
    "nativescript-carousel": "^3.1.1",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-drop-down": "^3.2.1",
    "nativescript-geolocation": "^4.2.3",
    "nativescript-google-maps-sdk": "^2.6.0",
    "nativescript-image-cache": "^1.1.6",
    "nativescript-imagepicker": "^5.0.2",
    "nativescript-iqkeyboardmanager": "^1.3.0",
    "nativescript-linearprogressbar-elica": "^1.0.0",
    "nativescript-localize": "^2.1.0",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-number-progressbar": "^1.0.0",
    "nativescript-orientation": "^2.2.0",
    "nativescript-phone": "^1.3.1",
    "nativescript-photoviewer": "^1.4.0",
    "nativescript-pulltorefresh": "^2.1.0",
    "nativescript-theme-core": "~1.0.2",
    "nativescript-ui-chart": "^3.5.0",
    "nativescript-ui-listview": "^3.5.1",
    "ng2-translate": "^5.0.0",
    "path": "^0.12.7",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^5.5.0",
    "tns-core-modules": "^4.0.0-2018-04-26-03",
    "utf8": "^3.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "~5.0.0",
    "@ngtools/webpack": "^1.10.2",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "clean-webpack-plugin": "~0.1.19",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "^0.7.1",
    "nativescript-dev-webpack": "^0.10.2",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "tns-platform-declarations": "^3.4.1",
    "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"
  }
`
TheOnlyMatt commented 6 years ago

Hello @alexma01, did you try to remove and reinstall android platform ?