NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function #5620

Closed monicaarepo closed 2 years ago

monicaarepo commented 2 years ago

Issue Description

I am developed the android and iOS Nativescript application. Now I started migrating the project. I had the issue while open the installed project Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function.

Package.json

{ "name": "sample", "main": "./src/main.ts", "version": "1.0.0", "private": true, "dependencies": { "@angular/animations": "~13.1.1", "@angular/common": "~13.1.1", "@angular/compiler": "~13.1.1", "@angular/core": "~13.1.1", "@angular/forms": "~13.1.1", "@angular/platform-browser": "~13.1.1", "@angular/platform-browser-dynamic": "~13.1.1", "@angular/router": "~13.1.1", "@mashdog/nativescript-accordion": "^7.0.6", "@nativescript/angular": "^12.2.0", "@nativescript/core": "~8.1.1", "@nativescript/firebase": "^11.1.3", "@nativescript/geolocation": "^8.0.2", "@nativescript/iqkeyboardmanager": "^2.0.0", "@nativescript/theme": "~3.0.1", "@ngtools/webpack": "^13.2.1", "@nstudio/nativescript-checkbox": "^2.0.4", "@nstudio/nativescript-loading-indicator": "^4.1.2", "@triniwiz/nativescript-youtubeplayer": "^4.1.4", "nativescript-drop-down": "^6.0.0", "nativescript-feedback": "^2.0.0", "nativescript-phone": "^3.0.2", "nativescript-ripple": "^4.0.1", "nativescript-store-ratings": "^1.0.0", "nativescript-theme-core": "^2.0.24", "nativescript-ui-listview": "^10.0.2", "rxjs": "~7.4.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular/compiler-cli": "~13.1.1", "@nativescript/android": "8.1.1", "@nativescript/ios": "8.1.0", "@nativescript/types": "~8.1.0", "@nativescript/webpack": "~5.0.0", "typescript": "~4.4.4" } }

I added the error screenshot for your reference

Error in Android Device

Screenshot_1644207929

Error in iOS device

   I had the pod issue in nativescript project
Screenshot 2022-02-05 at 1 22 17 PM

Please help me to fix this issue

Reproduction

No response

Relevant log output (if applicable)

No response

Environment

No response

Please accept these terms

NathanWalker commented 2 years ago

Hi @monicaarepo you can update this dependency (which is compatible with angular 13 - note the major matching version): "@nativescript/angular": "^13.0.0",

Then you will also want to add this to devDependencies: “@angular-devkit/build-angular”: “~13.1.1”

https://twitter.com/nativescript/status/1473762550667902978?s=21

Lastly on the Cocoapod issue you can just run: ‘pod repo update’ …as it states in the message.

then run: ‘ns clean’

monicaarepo commented 2 years ago

Hi @NathanWalker I tried the solution But it is not working for me. Still I have same issue. I had blank white screen while open the application.

Screenshot 2022-02-07 at 10 28 23 AM

Device Screenshot

Screenshot_1644219996

NathanWalker commented 2 years ago

@monicaarepo That doesn't look like the same issue actually. You solved one part of it. Your other issue is likely due to android build-tools. You can either uninstall build-tools 32 in Android Studio SDK Manager and ensure only build-tools 30 is installed or you can use the latest prerelease which supports latest gradle and build-tools 32 by doing this:

// install prerelease of upcoming cli release
npm install -g nativescript@next

Now modify your devDependencies to use the latest android runtime alpha (the 8.2 prerelease):

"@nativescript/android": "alpha",

Then ns clean and run again.

monicaarepo commented 2 years ago

Hi @NathanWalker I fixed the pod issue and the iOS application is installed the device successfully and I had some warnings in pods. But application is not open it quits suddenly.

Screenshots:

Screenshot 2022-02-08 at 10 14 50 AM Screenshot 2022-02-08 at 10 03 54 AM

Assertion Failed Screenshot:

Screenshot 2022-02-08 at 10 22 55 AM

How can I fix these issues? please help me to fix this issues.

NathanWalker commented 2 years ago

When updating an older project you may create a quick new project: ns create sample --ng and then you can compare settings (main.ts, tsconfig.json, etc.) just to see if anything else is off there. Sounds like something is not quite right configuration wise there. If possible to share your tsconfig.json and also the main.ts would be insightful.

monicaarepo commented 2 years ago

Hi,

I created the new project and shifted the old project components to 

the new project file. Here I send my tsconfig file and main.ts file kindly please refer the attachments.

Thanks & Regards, Monica A

// { // "compilerOptions": { // "module": "esnext", // "target": "es2017", // "moduleResolution": "node", // "experimentalDecorators": true, // "emitDecoratorMetadata": true, // "noEmitHelpers": true, // "noEmitOnError": true, // "skipLibCheck": true, // "lib": ["es2017", "dom"], // "baseUrl": ".", // "paths": { // "~/": ["src/"], // "@/": ["src/"] // } // }, // "include": ["src/tests//*.ts", "src/*/.ios.ts", "src//*.android.ts"], // "files": ["./src/main.ts", "./references.d.ts", "./src/polyfills.ts"], // "exclude": ["node_modules", "platforms", "e2e"] // }

{ "compilerOptions": { "module": "esnext", "target": "es2017", "experimentalDecorators": true, "emitDecoratorMetadata": true, "noEmitHelpers": true, "noEmitOnError": true, "skipLibCheck": true, "typeRoots": @.**"], "lib": [ "es6", "dom", "es2015.iterable", "es2017" ], "baseUrl": ".", "paths": { "~/": ["src/"], "@/": ["src/"] }, // "paths": { // "~/": [ // "src/" // ], // "": [ // "./node_modules/tns-core-modules/", // "./node_modules/" // ], // "@/": ["src/"] // }, "moduleResolution": "node", "removeComments": false, }, "files": ["./src/main.ts", "./references.d.ts", "./src/polyfills.ts"], "exclude": [ "node_modules", "platforms", "e2e" ] }

NathanWalker commented 2 years ago

Did you try using ‘ns migrate’ when first starting to migrate the project? That often helps make various adjustments for you and then you could continue to make manual adjustments as needed.

possible to post your webpack.config.js? I could look more tomorrow.

monicaarepo commented 2 years ago

Hi @NathanWalker

  Yes, I migrated the project using 'ns migrate' command after I had 

some node modules issue. So I created the new project and upgraded the used npm packages in project. after the component files , Providers and utils files are shifted to the new project then only application installed to the device successfully.

NathanWalker commented 2 years ago

Are you still having issue @monicaarepo ? You mentioned 'application install to the device successfully', does that mean everything works now?

monicaarepo commented 2 years ago

Hi @NathanWalker Yes now application is working fine and I got the some warning in pod file. LaunchImage is black screen in iPhone 8plus simulator.

Screenshots:

Screenshot 2022-02-09 at 9 25 48 AM

Launch Screen:

Simulator Screen Shot - iPhone 8 Plus - 2022-02-09 at 09 24 59

NathanWalker commented 2 years ago

Thanks @monicaarepo we'll go ahead and close this - on the splash screen with latest iOS adjusted some of their asset structures and often best thing to do is to generate fresh icon/splash screens, you can use this tool: https://images.nativescript.rocks/ Choose 'launch icons' and it defaults to also generate splash screens. that will download a zip containing all the right structures to swap your assets with. Also note that the simulator can often cache assets so when swapping/cleaning/building you may not see updates - running on actual device can often give better indicator.