-
-
Notifications
You must be signed in to change notification settings - Fork 40
Nativescript 4.1.0 using custom main activity with webpack #559
Comments
From @RadouaneRoufid on June 7, 2018 21:26 I also tried to add the activity in the appComponents of webpack.config.js
but same problem. |
There are some changes in nativescript-dev-webpack as described in this migration blog post. Apart from setting the MainActivity key, the custom activity should be added to `appComponents in webpack.config.js
Where the extended activity file is in |
As I mentionned, I also tried the following:
and I even tested with multiple variant but still get the error. |
@RadouaneRoufid I've just noticed that you have tried this approach. I will create a test application and post it here with the results. |
Thank you NickIliev. I updated my previous comment by adding the different approach I tested. |
@RadouaneRoufid I've used this project for testing purposes, and the webpack bundle was successful at my side. The changes in Let me know if the project is building on your side - you can also use it as a reference. |
I cloned your project, and I have the same error
I'm using tns--version 4.1.0 and node 8.11.2. is it same as you ? |
I'm still struggling with this with no solution !! Any idea to make it work ? or workaround it ? |
Oh! I was about to open another issue. I am facing same problem & I have written it here too: @tsonevn @NickIliev Please try to extend both Application & Activity in fresh project. It will always give error. |
@RadouaneRoufid Can you try
as you notice , no ts , no android |
@RoyiNamir I already tried your solution. The MainActivity is correctly recognized and picked up. I verified that in the console output and by generating a report. with a while without --bundle option, a MainActivity.java exists under org.bricool as below : So my mission now is to understand why and locate the code responsible for that generation. @NickIliev I really appreciate if you can tell us what plugin or code is reponsible for generating the java class ? |
@RadouaneRoufid do you use uglify when bundle? |
Yes. The commad I execute |
Can u plz try without. Iirc, we also had it and it was related. Also remove snapshot for now. Nick told me before something about it. Wait ill search ... Edit : found it : see what @NickIliev told me about snapshot. ( also , custom activity POV) |
You are right. It generates the Java class but I have now an error :
|
@RadouaneRoufid ^ try last comment :) (snapshot thingy in nick comment to me) |
I tried with vendor-platform.android.ts. It does not work. Note that this file should be removed according to latest migration guide. |
Sorry, I forgotted an important word in my last comment :). It does NOT work. the .java file is not generated. |
We updated the project today. - getting the same error
using in webpack :
And :
declared here : @RadouaneRoufid Did you find a solution? |
Replace
by
Do you have an import of |
@RadouaneRoufid I was looking at Nick's code - hence I was doing it without Will try now and update. Regarding the other question : main.aot.ts
Worth to mention After each change I do :
The update : Now I get only this error : |
@RadouaneRoufid How do you import the activity in the AOT file ? |
You don't have to import your activity in Try |
@RadouaneRoufid Did that - Same error : see that it doesn't have slashes :
this is NOt the folder. The folder is :
|
Can you output the result of
|
|
I have seen a Do you have a |
@RadouaneRoufid It ^ happens also in a plain test project. reported here. It's weird that you don't get this error. Can you delete all the app folder ( keeping only config and init files) and send only just the config files ( including hooks) project so I will make a comparison ? I can send you a picture which differences. ( beyond compare tool) |
What I suggest you is to do this : And tell me what you got. |
@RadouaneRoufid Will sure Do. ( when I'm at work). I wonder if @NickIliev 's code compiles (and runs!) with all those flags without error.... |
Hey @RadouaneRoufid, @RoyiNamir, @jibon57, could you please remove |
@vchimev So stuff like this :
should be ONLY in |
Hey there, I created this android-extend-ng sample app where I extended Android activity. Also, I added the
Could you please give it a try at your end? If successful, could you please try to Thanks, |
@vchimev Hi. In Windows - Still No. I'veDownloaded your project : ( Running first You can see the screen video here : final result : If you want to test on my win machine ( ...just say) |
I confirm that your project works on a Linux platform. I'm trying to figure out why it does not with mine. |
That's a known bug. If you have a Linux or Mac then can try. Windows has problem. I haven't tried the solution. Will try in morning |
^windows 10 , nope |
@RadouaneRoufid , I think new Android directory structure created that conflict with old. Is your project using old Android directory structure? |
You are totally right. there is a huge difference between my |
@RoyiNamir please check here: |
@jibon57 So ? it's not a problem with windows. it's a problem with how it was written to handle directories in windows. |
Thanks, Guys! Today we released I would be able to look into this tomorrow morning. |
Still no....
Video Result : https://i.imgur.com/eoQ4m50.gif webpackconfig file ( from your project) update@vchimev I took one more shot :
Then I got many errors : Full report : https://pastebin.com/raw/uEguqJ3y |
@vchimev I have tried but not working from my side too. I did like this:
Then in
But I got this error:
Then I have changed like this:
This time compile was successful like this:
But when the app was open that time it got crashed:
|
@RoyiNamir, @jibon57, |
Thanks @vchimev . Any work around so far? I can't use --env.snapshot too :( |
I have this error when trying to bundle with --env.snapshot
Any solution to this ? #568 |
Hey Guys, Let me just follow up that adding a custom android app component to the array on the top of the webpack.config.js file should be resolved to an absolute path, i.e. |
@vchimev , just for full closure summarize : all the problems:
And the right way is to use abosolute path like : resolve(__dirname, "app/activity.android.ts") Will be in resolved in 0.14.2? Or does some are resolved in 0.14 already ? |
Hey @RoyiNamir, the issue that absolute paths in However, absolute paths work fine on macOS/Linux and also extending activity and application should work fine with the configurations described in this comment. |
From @RadouaneRoufid on June 7, 2018 21:11
Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?
Tell us about the problem
I'm using a custom MainActivity declared as below in my nativescript project in a file named
MainActivity.js
. I'm importing this file in myvendor-platform.android.ts
and declare this activity as my MainActivity inAndroidManifest.xml
as<activity android:name="org.bricool.MainActivity"...
.I updated recently my project from tns 4.0.0 to tns 4.1.0 and nativescript-dev-webpack from 0.10.1 to 0.12.0. When I start the ns app in dev mode (tns run android). The app works fine, but when I build a release bundled, aoted, uglified and snapshoted, the build succeed but tns does not find the MainActivity on start.
I solved this problem in the previous version of nativescript by doing the following in the webpack.config.js
I tried the following with the last version of dev-webpack but it does not work.
Which platform(s) does your issue occur on?
Android
Please provide the following version numbers that your issue occurs with:
"dependencies": {
"@angular/animations": "~5.2.1",
"@angular/common": "^5.2.1",
"@angular/compiler": "^5.2.1",
"@angular/core": "^5.2.1",
"@angular/forms": "^5.2.1",
"@angular/http": "^5.2.1",
"@angular/platform-browser": "^5.2.1",
"@angular/platform-browser-dynamic": "^5.2.1",
"@angular/router": "^5.2.1",
"@ngrx/effects": "^4.1.1",
"@ngrx/router-store": "^4.1.1",
"@ngrx/store": "^4.1.1",
"@ngrx/store-devtools": "^4.1.1",
"@ngx-progressbar/core": "^3.0.1",
"@ngx-progressbar/http-client": "^3.0.1",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"arrive": "^2.3.1",
"bootstrap": "4.0.0-alpha.6",
"bootstrap-datepicker": "1.6.4",
"bootstrap-social": "^5.1.1",
"core-js": "^2.5.2",
"font-awesome": "4.7.0",
"fs": "0.0.1-security",
"hammerjs": "^2.0.8",
"i": "^0.3.6",
"lodash": "^4.17.4",
"materialize-css": "0.100.2",
"nativescript-angular": "~5.2.0",
"nativescript-background-http": "^3.2.7",
"nativescript-bottom-navigation": "^1.1.2",
"nativescript-bottombar": "^3.0.8",
"nativescript-cardview": "^2.0.5",
"nativescript-checkbox": "^3.0.3",
"nativescript-floatingactionbutton": "^4.1.3",
"nativescript-fresco": "^3.0.2",
"nativescript-imagepicker": "^5.0.0",
"nativescript-localstorage": "^1.1.5",
"nativescript-mediafilepicker": "^1.0.5",
"nativescript-modal-datetimepicker": "^1.1.0",
"nativescript-ng-shadow": "^2.1.0",
"nativescript-oauth": "^2.1.2",
"nativescript-phone": "^1.3.1",
"nativescript-photoviewer": "^1.4.0",
"nativescript-snackbar": "^2.0.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-listview": "^3.5.7",
"nativescript-ui-sidedrawer": "^4.1.1",
"ng2-validation": "^4.2.0",
"ngrx-store-freeze": "^0.1.9",
"ngx-pagination": "^3.0.3",
"node-sass": "^4.9.0",
"npm": "^4.2.0",
"osenv": "^0.1.4",
"path": "^0.12.7",
"reflect-metadata": "^0.1.12",
"rxjs": "^5.5.5",
"tether": "^1.4.3",
"tns-core-modules": "^4.1.0",
"url": "^0.11.0",
"velocity-animate": "^1.5.1",
"zone.js": "0.8.5"
},
"devDependencies": {
"@angular-devkit/core": "~0.6.3",
"@angular/compiler-cli": "^5.2.1",
"@ngtools/webpack": "~6.0.8",
"@types/googlemaps": "^3.30.8",
"@types/jasmine": "^2.8.5",
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
"clean-webpack-plugin": "~0.1.19",
"copy-webpack-plugin": "~4.5.1",
"css-loader": "~0.28.11",
"del": "^2.2.2",
"extract-text-webpack-plugin": "~3.0.2",
"fs-walk": "0.0.2",
"gulp": "^4.0.0",
"gulp-debug": "^3.1.0",
"gulp-exec": "^3.0.1",
"gulp-if": "^2.0.2",
"gulp-rename": "^1.2.2",
"gulp-spawn": "^0.4.0",
"gulp-string-replace": "^0.4.0",
"lazy": "1.0.11",
"mkdirp": "^0.5.1",
"nativescript-css-loader": "~0.26.1",
"nativescript-dev-android-snapshot": "^0.0.11",
"nativescript-dev-sass": "^1.6.0",
"nativescript-dev-typescript": "~0.7.0",
"nativescript-dev-webpack": "^0.12.0",
"nativescript-worker-loader": "~0.9.0",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.3.0",
"run-sequence": "^2.2.1",
"sass-loader": "~6.0.6",
"tns-platform-declarations": "^4.1.0",
"typescript": "~2.7.2",
"typescript-register": "^1.1.0",
"uglifyjs-webpack-plugin": "~1.2.5",
"webpack": "~4.6.0",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-sources": "~1.1.0",
"webpack-cli": "~2.1.3"
},
Please tell us how to recreate the issue in as much detail as possible.
1- Create a new ns project
2- Create a custom MainActivity
3- build the app with : tns build android --env.profile=mprod --bundle --env.aot --env.uglify --env.snapshot
Copied from original issue: NativeScript/NativeScript#5928
The text was updated successfully, but these errors were encountered: