{N} 6.0 migration: Error: Failed to load component from module: - nativescript

I’m upgrading my project to {N} 6.0 and hit an error I’m stuck on. Whenever my app displays a map page I get system errors:
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onClick failed
System.err: Error: Failed to load component from module: ./views/map-page/
System.err:
System.err: StackTrace:
System.err: Frame: function:'loadInternal', file:'file:///node_modules/tns-core-modules/ui/builder/builder.js:82:0
System.err: Frame: function:'', file:'file:///node_modules/tns-core-modules/ui/builder/builder.js:62:0
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame-common.js.FrameBase.navigate', file:'file:///node_modules/tns-core-modules/ui/frame/frame-common.js:129:0
So, this error occurs while the app is navigating to the map page, but the page’s .js file never receives control. I thought the problem might be that the google-maps-sdk uses a namespace definition,
<Page
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:maps="nativescript-google-maps-sdk"
navigatingTo="onNavigatingTo" navigatingFrom="onNavigatingFrom" loaded="onLoaded" class="page”>
But I have other pages with namespaces (sidedrawer) and they work OK. I’ve read through the {N} 6.0 migration docs and I can’t find anything that seems to match. At this point I’ve run out of ideas to pursue.

Wow, this was subtle... after further debugging and comparing to code that worked, this was the code in error:
// Navigate to map-page to show selected map
var navigationOptions = {
moduleName: "./views/map-page/",
context: { bindingContext: viewModel }
}
frame.topmost().navigate(navigationOptions);
The problem was the trailing slash on the moduleName. Once I removed that, the map page worked as expected, just as it had in {N} 3, 4, and 5.
Oh well, at least it's working!

Related

Error while using add ons simple ruler on ckeditor4

I want to use add ons simple ruler on ckeditor4 in my Codeigniter4 project. But I receive this kind of error. Already tried to browsing the solution in internet but I can't found the solution.
Uncaught ReferenceError: require is not defined
at ckeditor.js:1335:234
at ckeditor.js:1339:3160
Uncaught TypeError: Cannot read properties of undefined (reading 'split')
at Object.loadPart (ckeditor.js:568:143)
at l (ckeditor.js:279:29)
at a.<anonymous> (ckeditor.js:278:394)
at a.r (ckeditor.js:10:246)
at a.<anonymous> (ckeditor.js:12:91)
at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13:286)
at a.fireOnce (ckeditor.js:12:251)
at a.CKEDITOR.editor.CKEDITOR.editor.fireOnce (ckeditor.js:13:442)
at k (ckeditor.js:276:322)
at Object.<anonymous> (ckeditor.js:276:442)
The code from error require is not defined ckeditor.js:1335 is
window.noUiSlider=require("nouislider");window.$||(window.$=require("jquery"));
And code from error cannot read properties of undefined (reading 'split') ckeditor.js:568 is
split(",")[0]?CKEDITOR.scriptLoader.load(CKEDITOR.getUrl(a()+"skin.js"),function(){b(c,d)}):b(c,d)},getPath:function(a){return CKEDITOR.getUrl(d(a))},icons:{},addIcon:function(a,b,c,d){a=a.toLowerCase();this.icons[a]||(this.icons[a]={path:b,offset:c||0,bgsize:d||"16px"})},getIconStyle:function(a,b,c,d,e){var f;a&&(a=a.toLowerCase(),b&&(f=this.icons[a+"-rtl"]),
I confused because I'm using the feature CKEditor4 builder online and while using those add ons, always error. But if I remove the add ons(simple ruler), the error is gone. I already put jquery on my assets. And I dont know why this error happen. Are anyone have the solution of this? Thanks.

Calling js method onDestroy failed

I am trying to publish my app, but, Google play Pre-launch report return this Error: View not added to this instance. View: t(73) CurrentParent: t(69) ExpectedParent: t(66). This error was happens multiple times. I did add onDestroy on each of my components.
The app just reproduce a web page from Wordpress. (Client requirement).
I use WebView component to achieve that.
After I apply my changes, the amount error reduced to 1. Now, only happen in Galaxy S9.
Well, at this point I don’t know where can I fix that.
Here the error:
FATAL EXCEPTION: main
Process: org.fcoe.iplan, PID: 26666
java.lang.RuntimeException: Unable to destroy activity {org.fcoe.iplan/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onDestroy failed
Error: View not added to this instance. View: t(73) CurrentParent: t(69) ExpectedParent: t(66)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4603)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4621)
at android.app.ActivityThread.-wrap5(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: com.tns.NativeScriptException: Calling js method onDestroy failed
Error: View not added to this instance. View: t(73) CurrentParent: t(69) ExpectedParent: t(66)
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
at com.tns.Runtime.callJSMethod(Runtime.java:1160)
at com.tns.Runtime.callJSMethod(Runtime.java:1138)
at com.tns.Runtime.callJSMethod(Runtime.java:1134)
at com.tns.NativeScriptActivity.onDestroy(NativeScriptActivity.java:39)
at android.app.Activity.performDestroy(Activity.java:7462)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1255)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnDestroy(MonitoringInstrumentation.java:1)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4590)
... 9 more
My coworker suggest to add StackLayout tag around <page-router-outlet></page-router-outlet> in app.component.html.
I did his suggestion and all works fine in Google Play tests.
Here the code looks like:
<StackLayout>
<page-router-outlet></page-router-outlet>
</StackLayout>

Xamarin Prism Unable to navigate to LoginPageViewModel

I am trying to make my Xamarin Project use MVVM with Prism and DryIoc.
I mostly want to use AutoRegistration like below:
[AutoRegisterForNavigation]
...
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
//Pages
containerRegistry.RegisterForNavigation<NavigationPage>();
//Services
containerRegistry.RegisterSingleton<ILocalDatabase, LocalDatabase>();
containerRegistry.RegisterSingleton<IUserProfileDataStore, UserProfileDataStore>();
containerRegistry.RegisterSingleton<IApplicationSettings, ApplicationSettings>();
containerRegistry.RegisterSingleton<ILogger, Logger>();
containerRegistry.RegisterSingleton<IApiService, ApiService>();
containerRegistry.RegisterSingleton<IUserSession, UserSession>();
containerRegistry.Register<IBrowser, BrowserImplementation>();
containerRegistry.Register<IConnectivity, ConnectivityImplementation();
containerRegistry.Register<IFileSystem, FileSystemImplementation>();
containerRegistry.Register<ICoreServices, CoreServices>();
}
I have also tried Manual Registration:
containerRegistry.RegisterForNavigation<LoginPage, LoginPageViewModel>();
Neither works, It hits the Login Page code behind then breaks with the following error:
Exception - High: Prism.Ioc.ContainerResolutionException:
An unexpected error occurred while resolving 'AppetiteApp.ViewModels.LoginPageViewModel' --->
DryIoc.ContainerException: code: UnableToResolveUnknownService; message: Unable to resolve
Resolution root AppetiteApp.ViewModels.LoginPageViewModel
with passed arguments [value(Prism.Navigation.ErrorReportingNavigationService)]
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
I've also tried using a Linker file setting it's build action to "linkdescription"
As for my Login Page here is the declaration
public LoginPageViewModel(ICoreServices coreServices)
: base(coreServices)
The constructor of LoginPageViewModel requires the ICoreServices argument which is registered.
The error message says that the LoginPageViewModel itself is unknown to the IoC - it means the type LoginPageViewModel is not directly registered and not found through dynamic registrations or unknown service resolvers.
I am not a user of the Xamarin Prism so I am not sure about its mechanism for registering the view models.
Btw, this part of error
Resolution root AppetiteApp.ViewModels.LoginPageViewModel
with passed arguments [value(Prism.Navigation.ErrorReportingNavigationService)]
basically means the view-model was resolved via the foollowing call resolver.Resolve(typeof(LoginPageViewModel), args: new[] { errorReportingNavigationService })
Hope it will help you or someone knowledgeable in Xamarin to track the error cause.
So Once I investigated Inside of ICoreServices I commented out each of the dependencies then discovered that IUserSession was the once causing problems then I dug into that and discovered that the dependences for IAppInfo and IVersionTracking were missing in the App.Xaml.cs registr tyepes so I added that and then it worked!
containerRegistry.Register<IAppInfo, AppInfoImplementation>();
containerRegistry.Register<IVersionTracking, VersionTrackingImplementation>();

NativeScript error - java.lang.OutOfMemoryError

I'm creating a NativeScript app and testing it on an Android emulator. Unfortunately I can't replicate this, but occasionally I get the error below.
The app follows simple "parent-child" template. Going from the Parent to a Child; back to the Parent and then to a different Child - and repeating multiple times. Each Child displays text and an image.
I'm not sure if this is unique to Android (vs iOS) or an emulator (vs physical device).
An uncaught Exception occurred on "main" thread.
java.lang.OutOfMemoryError: Failed to allocate a 18925068 byte allocation with 11023464 free bytes and 10MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
at android.graphics.Bitmap.createBitmap(Bitmap.java:739)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:615)
at org.nativescript.widgets.image.Fetcher.scaleAndRotateBitmap(Fetcher.java:499)
at org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromFile(Fetcher.java:474)
at org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:263)
at org.nativescript.widgets.image.Worker.loadImage(Worker.java:119)
at org.nativescript.widgets.ImageView.loadImage(ImageView.java:197)
at org.nativescript.widgets.ImageView.onAttachedToWindow(ImageView.java:58)
at android.view.View.dispatchAttachedToWindow(View.java:14514)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4348)
at android.view.ViewGroup.addView(ViewGroup.java:4145)
at android.view.ViewGroup.addView(ViewGroup.java:4086)
at android.view.ViewGroup.addView(ViewGroup.java:4059)
at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:190)
at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:63)
at android.transition.Visibility.onDisappear(Visibility.java:423)
at android.transition.Visibility.createAnimator(Visibility.java:247)
at android.transition.Transition.createAnimators(Transition.java:732)
at android.transition.TransitionSet.createAnimators(TransitionSet.java:405)
at android.transition.Transition.playTransition(Transition.java:1777)
at android.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:306)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Use decodedWidth / decodedHeight on Image component. Also set the largeHeap property on your application tag of your AndroidManifest.xml
<application
android:largeHeap="true" ....

NativeScript Android Background Service

I am developing NativeScript android application. I am new to NativeScript. I want to run background service, which is checking service periodically and give notifications to user even though app not opened on device. I followed instructions from Nativescript site
https://www.nativescript.org/blog/using-android-background-services-in-nativescript
But when i call setupAlarm function, i received error can't instantiate class com.tns.notifications.NotificationIntentService; no empty constructor
please help me. i give full exception details below
The application crashed because of an uncaught exception. You can look at "stackTrace" or "nativeException" for more detailed information about the exception.
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to instantiate service com.tns.notifications.NotificationIntentService: java.lang.InstantiationException: can't instantiate class com.tns.notifications.NotificationIntentService; no empty constructor
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2543)
at android.app.ActivityThread.access$1800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: can't instantiate class com.tns.notifications.NotificationIntentService; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2540)
... 10 more
To solve the no empty constructor issue, you can use nativescript-android-utils like this:
Install:
npm install nativescript-android-utils --save
In you code:
com.pip3r4o.android.app.IntentService.extend("com.mypackage.MyClass", {
onHandleIntent: function(){}
});
Now, com.mypackage.MyClass will have an empty constructor.
i found working nativescript android background service project from here
https://github.com/NativeScript/sample-android-background-services
The latest release of Nativescript allows you to use workers for multithreading applications. I believe it's what you should be using. In the tutorial you provided they also mention using web workers in the future.
What’s next
In the upcoming releases we will be rolling out support for the Web
Workers feature in NativeScript, allowing you to execute code in a
background thread, all through Angular/JavaScript.
Hope it helps.

Resources