Getting error after update NativeScript to 5.0.0 - nativescript

I am new to NativeScript. After I have updated NativeScript to 5.0.0, When I create default project and run using tns run android command, It is giving me following error :
System.err: com.tns.NativeScriptException:
System.err: Calling js method onViewAttachedToWindow failed
System.err: TypeError: this._context.getSupportFragmentManager is not a function
System.err: File: "file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js, line: 190, column: 46
System.err: StackTrace:
System.err: Frame: function:'View._getRootFragmentManager', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 190, column: 47
System.err: Frame: function:'View._getFragmentManager', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 215, column: 32
System.err: Frame: function:'Frame._processNextNavigationEntry', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 134, column: 28
System.err: Frame: function:'Frame._onAttachedToWindow', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 118, column: 14
System.err: Frame: function:'AttachListener.onViewAttachedToWindow', file:'file:///data/data/org.nativescript.DemoApp/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 35, column: 27
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:983)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:967)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:959)
System.err: at com.tns.gen.java.lang.Object_frame_29_36_AttachListener.onViewAttachedToWindow(Object_frame_29_36_AttachListener.java:17)
System.err: at android.view.View.dispatchAttachedToWindow(View.java:13554)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2690)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2697)
System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1322)
System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:580)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:550)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
System.err: at android.os.Handler.handleCallback(Handler.java:739)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:135)
System.err: at android.app.ActivityThread.main(ActivityThread.java:5343)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at java.lang.reflect.Method.invoke(Method.java:372)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
ActivityManager: Process org.nativescript.DemoApp (pid 22172) has died
Please help me with the answer. I am facing this issue since I have updated my NativeScript Version.

Do you have something like
class MainActivity extends android.app.Activity {
I updated the Activity to AppCompatActivity for nativescript version 5
class Activity extends android.support.v7.app.AppCompatActivity {
and the error is gone.
but if you have startActivityForResult, maybe you will get other new errors then.

Most likely you have upgraded just the NativeScript CLI and not the project's dependencies and runtime. Follow the detailed upgrade instruction in this documentation section and make sure that you have migrated your entire project by updating the runtimes ('tns-android' and/or 'tns-ios'), the modules ('tns-core-modules') and all related plugins/dependencies.

I have solved this issue. Actually I was having issue with AndroidStudio. By doing ClearCache in AndroidStudio my problem get solved. It might be space issue that AndroidStudio was occupying in disc so my NativeScript application was not getting enough space.

Related

What causes a negative event timeout error to occur?

I am getting an error in my model (shown below) saying an event is being scheduled in the past. I have run into this error before in other models, but I don't know why or how it occurs. Root.arrival is not the name of anything in my model, so it seems to be something internal to the AnyLogic engine. Unfortunately the stack trace doesn't give me any info about where this happens in my model, so I don't know how to diagnose the origin. Does anyone know generally why/when/how a negative timeout may occur? Thanks in advance.
java.lang.RuntimeException: root.arrival: Trying to schedule an event in the past. Negative timeout: -0.07519763751588471
at com.anylogic.engine.Engine.error(Unknown Source)
at com.anylogic.engine.EventOriginator.d(Unknown Source)
at com.anylogic.engine.EventTimeout.restartTo(Unknown Source)
at com.anylogic.engine.jk$d.a(Unknown Source)
at com.anylogic.engine.jk.addMovingAgent(Unknown Source)
at com.anylogic.engine.g.d(Unknown Source)
at com.anylogic.engine.g.d(Unknown Source)
at com.anylogic.engine.g.d(Unknown Source)
at com.anylogic.engine.g.d(Unknown Source)
at com.anylogic.engine.be.d(Unknown Source)
at com.anylogic.engine.be.moveToInTime(Unknown Source)
at com.anylogic.engine.be.moveToInTime(Unknown Source)
at com.anylogic.engine.be.moveTo(Unknown Source)
at com.anylogic.engine.ExtAgentWithSpatialMetricsDelegate.moveTo(Unknown Source)
at com.anylogic.libraries.processmodeling.MoveTo.c(Unknown Source)
at com.anylogic.libraries.processmodeling.MoveTo.d(Unknown Source)
at com.anylogic.libraries.processmodeling.MoveTo.a(Unknown Source)
at com.anylogic.libraries.processmodeling.MoveTo.a(Unknown Source)
at com.anylogic.libraries.processmodeling.MoveTo$1.onEnter(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay$9.onEnter(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.b(Unknown Source)
at com.anylogic.libraries.processmodeling.InPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.InPort.receiveImmediately(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.PlainTransfer$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.PlainTransfer$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.action(Unknown Source)
at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal$a.execute(Unknown Source)
at com.anylogic.engine.LibraryEventHandler$l.execute(Unknown Source)
at com.anylogic.engine.Engine.d(Unknown Source)
at com.anylogic.engine.Engine.runFast(Unknown Source)
at com.anylogic.engine.Engine.runFast(Unknown Source)
Lots of things can cause it. In your case, it seems linked to a MoveTo block so you likely set the agent speed to a negative value.
Or maybe you defined it by "Trip time" and set that to a negative value:
In any case, it is worth learning to isolate such problems first. Use traceln commands to nudge yourself closer to the issue. Remove blocks, ...
Most of all: keep a history of your model dev so you can always revert to a version that does not trigger this. And then you have your root cause

html2pdf do close of undefined on printing second time

I'm facing an issue related to PDF conversion. When convert any HTML web view initially it will create a PDF file successfully. But when i press back button and came back to convert page and press convert again it will give unknown error.
the stack trace is given below. Since the web pack kind of building app won't show line number where the error is. I couldn't identify the problem.
The web pack always show error in vendor.js whatever the error might be So, please tell me why the error is.
Frame: function:'doClose', file:'file:///data/data/org.nativescript.SuperMarket/files/app/vendor.js', line: 863, column: 22
System.err: Frame: function:'push.../node_modules/nativescript-html2pdf/html2pdf.js.exports.html2PdfFile', file:'file:///data/data/org.nativescript.SuperMarket/files/app/vendor.js', line: 834, column: 9
System.err: Frame: function:'webpackHotUpdate../views/htmlView/htmlView-page.js.exports.print', file:'file:///data/data/org.nativescript.SuperMarket/files/app/bundle.97e2cabb5862869d3b07.hot-update.js', line: 53, column: 25
System.err: Frame: function:'push.../node_modules/tns-core-modules/data/observable/observable.js.Observable.notify', file:'file:///data/data/org.nativescript.SuperMarket/files/app/vendor.js', line: 8847, column:
23
System.err: Frame: function:'push.../node_modules/tns-core-modules/data/observable/observable.js.Observable._emit', file:'file:///data/data/org.nativescript.SuperMarket/files/app/vendor.js', line: 8864, column: 18
System.err: Frame: function:'ClickListenerImpl.onClick', file:'file:///data/data/org.nativescript.SuperMarket/files/app/vendor.js', line: 18674, column: 23
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err: at com.tns.gen.java.lang.Object_vendor_18667_32_ClickListenerImpl.onClick(Object_vendor_18667_32_ClickListenerImpl.java:18)
System.err: at android.view.View.performClick(View.java:5215)
System.err: at android.view.View$PerformClick.run(View.java:21196)
System.err: at android.os.Handler.handleCallback(Handler.java:742)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:157)
System.err: at android.app.ActivityThread.main(ActivityThread.java:5601)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
System.err: Caused by: ExceptionConverter: java.io.IOException: The document has no pages.
System.err: Caused by: java.io.IOException: The document has no pages.
System.err: at com.itextpdf.text.pdf.PdfPages.writePageTree(PdfPages.java:112)
System.err: at com.itextpdf.text.pdf.PdfWriter.close(PdfWriter.java:1256)
System.err: at com.itextpdf.text.pdf.PdfDocument.close(PdfDocument.java:901)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err: at com.tns.gen.java.lang.Object_vendor_18667_32_ClickListenerImpl.onClick(Object_vendor_18667_32_ClickListenerImpl.java:18)
System.err: at android.view.View.performClick(View.java:5215)
System.err: at android.view.View$PerformClick.run(View.java:21196)
System.err: at android.os.Handler.handleCallback(Handler.java:742)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:157)
System.err: at android.app.ActivityThread.main(ActivityThread.java:5601)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
As the error suggests java.io.IOException: The document has no pages. Looks like after back button press, cache/history is cleared and webview is empty.
You can store the context in appsettings.

Uncaught (in promise) TypeError: Cannot read property 'geometry' of undefined

I am trying to load a workshop (glTF file) in my scene but all I get is the error message
Uncaught (in promise) TypeError: Cannot read property 'geometry' of undefined at GLTFLoader.js:2572
I tried opening the file in Three.js editor and in glTF Viewer and it worked, I also checked the file with glTF Validator and it said the file was valid but I can't figure out why it doesn't with me. I also tried to open another glTF model found on the Internet with my code and it worked just fine.
new Promise(function(resolve, reject) {
const manager = new THREE.LoadingManager();
const gltfloader = new THREE.GLTFLoader(manager);
gltfloader.setCrossOrigin('anonymous');
gltfloader.setDRACOLoader(new THREE.DRACOLoader());
gltfloader.load("data/gltf/salleTP/salleTP.gltf", function (gltf) {
const content = gltf.scene || gltf.scenes[0];
scene.add(content);
}, undefined, reject);
});
It seems you are using three.js R102 and the respective GLTFLoader version. When loading your glTF asset, a known error in GLTFLoader occurs that was fixed with R103 (see https://github.com/mrdoob/three.js/pull/15881). After upgrading your code base to the latest three.js version, your asset loads fine.
three.js R104

Nativescript Carousel control not working

I am trying to use Nativescript-Carousel plugin to show multiple Google Places. However whenever i set the dataset for Carousel control, i get below exception
System.err: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 0, found: 20 Pager id: 9 Pager class: class android.support.v4.view.ViewPager Problematic adapter: class com.tns.gen.android.support.v4.view.PagerAdapter_index_222_28_CarouselPagerAdapterClassInner
System.err: at android.support.v4.view.ViewPager.populate(ViewPager.java:1135)
System.err: at android.support.v4.view.ViewPager.populate(ViewPager.java:1084)
System.err: at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
System.err: at android.view.View.measure(View.java:19857)
System.err: at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
System.err: at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
System.err: at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
System.err: at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
System.err: at android.view.View.measure(View.java:19857)
System.err: at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
System.err: at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
System.err: at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
System.err: at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
System.err: at android.view.View.measure(View.java:19857)
System.err: at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
System.err: at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
System.err: at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
System.err: at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
System.err: at android.view.View.measure(View.java:19857)
System.err: at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
System.err: at org.nativescript.widgets.ContentLayout.onMeasure(ContentLayout.java:32)
System.err: at android.view.View.measure(View.java:19857)
System.err: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
System.err: at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
System.err: at android.view.View.measure(View.java:19857)
System.err: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
System.err: at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
System.err: at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
System.err: at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
System.err: at android.view.View.measure(View.java:19857)
System.err: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
System.err: at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
System.err: at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
System.err: at android.view.View.measure(View.java:19857)
System.err: at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
System.err: at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:686)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:621)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
System.err: at android.os.Handler.handleCallback(Handler.java:751)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:154)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Here is my code
this.gpsLocationService.getGpsLocation()
.then((location) => {
this.latitude = location[0];
this.longitude = location[1];
this.nearesthelpService.getNearByPlaces(this.latitude, this.longitude, 5000, 'pharmacy')
.subscribe((res) => {
this.places = (<any>res).results;
console.dir(this.places)
let placeDetails: PlaceDetails[] = []
this.places.forEach((place) => {
this.nearesthelpService.getNearByPlaceDetails(place.reference).subscribe((details: PlaceDetails) => {
console.log(details.result.name);
placeDetails.push(details);
if (placeDetails.length === this.places.length){
this.placeDetails = placeDetails;
}
})
});
});
});
Also here is my template
<GridLayout row="1" *ngIf="placeDetails.length > 0">
<Carousel #carousel (pageChanged)="onPageChanged($event)">
<ng-template ngFor let-subitem [ngForOf]="placeDetails">
<CarouselItem>
<GridView rows="auto,*">
<Label [text]="placedetail.result?.name"></Label>
</GridView>
</CarouselItem>
</ng-template>
</Carousel>
</GridLayout>
i tried all different ways so that the dataset which is attached to Carousel control is not changed again. As it can be seen above, i also first calculated results in a local object and then attached the same to class variable. However no luck. Any idea why its failing?
Just to add, if i assign the datasource as a static array instead of placedetails, this control does not throw any issue. However when the result is assigned via API result, it does not work.
Just to add, I read on the plugin page that for angular contents can't be changed dynamically. However my requirement is not to change contents once they are received.
Unfortunately there is no answer to this question. Github page mentions that
(Angular) Only static slides work, the dynamic ones with binding do not (for now).
I was assuming that assigning the data for the first time to an empty array would still be a static slide. However it looks like not the case. If you keep your data ready ahead of time, then you may be able to assign it on initialisation itself.

Unable to show the context menu in ckeditor

can anyone please help me out for the following error:
Uncaught TypeError: Cannot read property 'show' of undefined
at line editor.contextMenu.show(editor.document.getBody(), null, x,
y); in plugin.js

Resources