Repository navigation
Description
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 !
Activity
petekanev commentedon Jan 3, 2018
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:
new Workerconstructs?)"ns-project\platforms\android\build-tools\android-static-binding-generator\jsFilesParameters.txt"file? - It is possible, in rare cases that your node_modules and application files end up twice in your application package, and that could potentially cause slow-downs and the error that you are seeing.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 commentedon Jan 3, 2018
Hi, thank you for paying attention to my issue.
(After googling I found out that it is used for multithreading, so as I didn't code anything about multithreading, I guess it is not implemented in my project)
I am going to try updating a sample project to the version 3.4, and tell you if I experience the same problems
petekanev commentedon Jan 3, 2018
@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 --bundlecommand?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 commentedon Jan 3, 2018
When
tns run android --bundle, the app builds and crashes on startup on the device, the same happens whentns run android --bundle --env.snapshot. The only error is :But when
tns run android --bundle --env.snapshot --env.uglifythe error on build occurs. Here is the complete output :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 commentedon Jan 3, 2018
Okay so I updated my sample project, and I get the same error than I have earlier solved on my real project :
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 commentedon Jan 4, 2018
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 :
Changing the dependencies from 2.3.3 to 3.0.1 in the android/build.gradle file seems to do the trick
The following issue is :
I had to execute these instructions to have my sdk licenses accepted :
sdkmanager --updatesdkmanager --licensesexport ANDROID_HOME=/usr/local/share/android-sdkStill 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) :
petekanev commentedon Jan 4, 2018
@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 commentedon Jan 4, 2018
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 commentedon Jan 4, 2018
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
PS : I have an error when running
npm i -g nativescriptI don't know if it is related, but I must run uninstall script then install to update Nativescript
jibon57 commentedon Jan 7, 2018
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
petekanev commentedon Jan 8, 2018
@jibon57 according to our QAs the
template-drawer-navigation-ngisn't in a webpackable state yet, but is pending a proper webpackable release later this week.cc @dtopuzov
TheOnlyMatt commentedon Jan 8, 2018
Ok thank you, it might be the same problem on my side, I am also using the drawer template.
6 remaining items
TheOnlyMatt commentedon Jan 17, 2018
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 commentedon Jan 17, 2018
@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.txtandns-project\platforms\android\build-tools\android-static-binding-generator\bindings.txtagain so I can analyze them further.And, does the build go through without passing the uglify option?
TheOnlyMatt commentedon Jan 17, 2018
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 commentedon Jan 17, 2018
@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.OnItemSelectedListenerinterface, and the otherandroid.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. - #923
TheOnlyMatt commentedon Jan 17, 2018
Ok nice to hear that !
Thanks for your support, I am waiting for your updates :)
petekanev commentedon Jan 17, 2018
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 commentedon Jan 17, 2018
Ok I guess I should have read more carefully the plugins docs ...
So I pasted their uglify code in the webpack config file
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 commentedon Jan 17, 2018
@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 commentedon Jan 17, 2018
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 :
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 commentedon Jan 17, 2018
@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 commentedon Jan 17, 2018
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 commentedon Jan 18, 2018
@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 commentedon Apr 29, 2018
Hi @TheOnlyMatt ,
i have same problem (JAVA io.Exception) but when i start
tns build android --bundle.Any idea?
TheOnlyMatt commentedon May 18, 2018
Hello @alexma01, did you try to remove and reinstall android platform ?