Android-runtime: App doesn't load with the new custom Application\Activity support

Created on 1 Sep 2016  Â·  22Comments  Â·  Source: NativeScript/android-runtime

Did you verify this is a real problem by searching [Stack Overflow]

Yes

Tell us about the problem

When you run the demo it says app is deployed to the device, but no app actually runs\loads. if you MANUALLY run it, it just crashes.
image

Please provide the following version numbers that your issue occurs with:

All latest as of 2.2.1

Did the error happen while the app was being constructed? (buildtime error)

No, although there is an error @Pip3r4o fixed generating the Application class (generates super.getLock()), I think it's a non issue with the latest internal master?

Did the error happen while the app was executing? (runtime error)

09-01 15:55:49.622    98    98 D Genyd   : Received Set Clipboard
09-01 15:55:49.622    98    98 D Genymotion: Received Set Clipboard
09-01 15:55:52.191   731  1105 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.nativescript.demo/org.myApp.MainActivity (has extras)} from uid 10008 on display 0
09-01 15:55:52.236  2551  2551 I art     : Late-enabling -Xcheck:jni
09-01 15:55:52.242   731  1108 I ActivityManager: Start proc 2551:org.nativescript.demo/u0a66 for activity org.nativescript.demo/org.myApp.MainActivity
09-01 15:55:52.248   425   804 D AudioFlinger: mixer(0xf1e40000) throttle end: throttle time(10)
09-01 15:55:52.255  2551  2551 I TNS.Native: NativeScript Runtime Version 2.2.0, commit 14f63dd23a93cb0d1af9623d72ccf166e722e35a
09-01 15:55:52.255  2551  2551 D TNS.Native: JNI_ONLoad
09-01 15:55:52.255  2551  2551 D TNS.Native: JNI_ONLoad END
09-01 15:55:52.350  1107  1252 E Surface : getSlotFromBufferLocked: unknown buffer: 0xeeacbee0
09-01 15:55:52.405  2551  2551 D TNS.Native: V8 version 4.7.80
09-01 15:55:52.437  2551  2551 D TNS.Native: lenNodes=69396, lenNames=748833, lenValues=877953
09-01 15:55:52.437  2551  2551 D TNS.Native: time=0
09-01 15:55:52.479  2551  2551 D TNS.Java: Enabling NativeScript Debugger Agent
09-01 15:55:52.487  2551  2551 D AndroidRuntime: Shutting down VM
09-01 15:55:52.487  2551  2551 W System.err: java.lang.RuntimeException: Unable to create application org.myApp.Application: com.tns.NativeScriptException: JavaScript object for Java ID 0 not found.
09-01 15:55:52.487  2551  2551 W System.err: Attempting to call method onCreate
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.ActivityThread.-wrap1(ActivityThread.java)
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
09-01 15:55:52.488  2551  2551 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:102)
09-01 15:55:52.488  2551  2551 W System.err:    at android.os.Looper.loop(Looper.java:148)
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:5417)
09-01 15:55:52.488  2551  2551 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
09-01 15:55:52.488  2551  2551 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
09-01 15:55:52.488  2551  2551 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-01 15:55:52.488  2551  2551 W System.err: Caused by: com.tns.NativeScriptException: JavaScript object for Java ID 0 not found.
09-01 15:55:52.488  2551  2551 W System.err: Attempting to call method onCreate
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.callJSMethodNative(Native Method)
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:862)
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.callJSMethodImpl(Runtime.java:727)
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:713)
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:694)
09-01 15:55:52.488  2551  2551 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:684)
09-01 15:55:52.488  2551  2551 W System.err:    at org.myApp.Application.onCreate(Application.java:22)
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
09-01 15:55:52.488  2551  2551 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
09-01 15:55:52.488  2551  2551 W System.err:    ... 8 more
09-01 15:55:52.490   731   742 I ActivityManager: START u0 {flg=0x14008000 cmp=org.nativescript.demo/com.tns.ErrorReportActivity (has extras)} from uid 10066 on display 0
09-01 15:55:52.495   731   742 D         : HostConnection::get() New Host Connection established 0xdbaaa080, tid 742
09-01 15:55:52.526   744   744 E EGL_emulation: tid 744: eglCreateSyncKHR(1215): error 0x3004 (EGL_BAD_ATTRIBUTE)
09-01 15:55:52.651  2551  2551 I Process : Sending signal. PID: 2551 SIG: 9
09-01 15:55:52.667   731  1108 I ActivityManager: Process org.nativescript.demo (pid 2551) has died
09-01 15:55:52.683  2574  2574 I art     : Late-enabling -Xcheck:jni
09-01 15:55:52.690   731  1108 I ActivityManager: Start proc 2574:org.nativescript.demo/u0a66 for activity org.nativescript.demo/com.tns.ErrorReportActivity
09-01 15:55:52.708  2574  2574 I TNS.Native: NativeScript Runtime Version 2.2.0, commit 14f63dd23a93cb0d1af9623d72ccf166e722e35a
09-01 15:55:52.708  2574  2574 D TNS.Native: JNI_ONLoad
09-01 15:55:52.708  2574  2574 D TNS.Native: JNI_ONLoad END
09-01 15:55:52.763  2574  2590 D OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-01 15:55:52.772  2574  2574 D         : HostConnection::get() New Host Connection established 0xe7d3f240, tid 2574
09-01 15:55:52.831  2574  2590 D libEGL  : loaded /system/lib/egl/libEGL_emulation.so
09-01 15:55:52.832  2574  2590 D libEGL  : loaded /system/lib/egl/libGLESv1_CM_emulation.so
09-01 15:55:52.836  2574  2590 D libEGL  : loaded /system/lib/egl/libGLESv2_emulation.so
09-01 15:55:52.839  2574  2590 D         : HostConnection::get() New Host Connection established 0xeead2800, tid 2590
09-01 15:55:52.861  2574  2590 I OpenGLRenderer: Initialized EGL, version 1.4
09-01 15:55:52.907  2574  2590 W EGL_emulation: eglSurfaceAttrib not implemented
09-01 15:55:52.907  2574  2590 W OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xeead35a0, error=EGL_SUCCESS
09-01 15:55:53.111   731   756 I ActivityManager: Displayed org.nativescript.demo/com.tns.ErrorReportActivity: +432ms (total +879ms)
^C

Please tell us how to recreate the issue in as much detail as possible.

https://github.com/sitefinitysteve/nativescript-auth0/commits?author=sitefinitysteve

  • Run the Demo app
done bug

All 22 comments

Sidenote, when we do have the custom activity it seems that it's a COMMON issue for the app to not start, related to this issue https://github.com/NativeScript/nativescript-cli/issues/2028

Hi @sitefinitysteve,
we know what the issue is and will fix as soon as possible.

...when we do have the custom activity it seems that it's a COMMON issue for the app to not start

The issue in the issue you're pointing to is that cli has a hardcoded activity to start, and even if you have a custom activity it's not respected. The cli team is working on fixing this behavior.

Your particular issue is different and is connected with the static binding generator only.

Oh yeah sorry i know they aren't related, just saying it also happens with the custom activity.

So this issue preventing the auth0 custom activity from loading is being addressed and is a real issue?

Problem

Current problem is in the new implementation of the static binding generator.
When a user has implemented an interface in the application, this interface shouldn't have the check

if(isInitialized) {
    super.interfaceMethodName();
}

because interfaces have no such implemented methods.

Solution

Remove isInitialized check from the new implementation of the static binding generator for methods that come from interface implementations. It should check if the implemented method comes from an interface or from an inherited class and have the corresponding functionality.

@Plamen5kov Are you asking me to do this, or is this just a note for whomever is fixing it in the generator?

@sitefinitysteve i'm just leaving it as a note, so we fix the issue faster when we get the time.

Thx for 2.4ing it guys

How we looking on this, Auth0-able post 2.4 perhaps?

@sitefinitysteve you can test that with the master branch available on @next. We are positive that with some recent fixes to class generation most known bugs have been eliminated.

I love the confidence 🌮

Hi @sitefinitysteve
Here are some quick updates. I made some changes (already in master branch) in the runtime and tested it with the current tip 9b9199e of your demo app. So after the bug fix the runtime now shows the actual error.

screenshot_2016-10-12-12-18-46

It seems that the problem now is in the application module initialization logic. I will look further at it.

Oh yeah, I can look into it now :) Glad were now here though!

Hi @sitefinitysteve

Here are my findings. I made the following changes in order to make the app working.

  • I set emitDecoratorMetadata to false here
  • I deleted this line
  • I changed this line to .closable(true) (probably you will make it configurable)

After these changes your app starts successfully.

Oh AWESOME... so this is Broadcast receivers aside though right, on a core level the Lock screen loads

@slavchev Okay so since 2.4 is out, I pulled this all down to finally get it up and running... now it builds, but at runtime the demo just throws like a million CallJSMethodNative items then just crashes out... I never get to see anything

http://www.screencast.com/t/6ytG9j9722P

Hi @sitefinitysteve

Today I double checked the issue and I confirm the issue is fixed. Please check your runtime version.

11-18 11:05:26.073 24046-24046/org.nativescript.demo I/TNS.Native: NativeScript Runtime Version 2.4.0, commit 440897629007580a6faafaddb79d9a057daf4120

Both our QA team and I tested against 9b9199e. Also, please make sure you follow the instructions given above.

Yeah I followed the instructions before posting... I updated all my google libs, and removed the app from geny... now she loads! On with the struggle though to get this properly working, thx guys :)

Yep on 2.4... so now I did have it loading after I killed the app on geny and reset the platforms... HOWEVER

Auth0 appears to have changed their API entirely to DRASTICALLY simplify and not require a custom Application
https://auth0.com/docs/libraries/lock-android

I believe I have implemented it per the docs, but I just get a million tns runtime errors when I try to build the lock
https://github.com/sitefinitysteve/nativescript-auth0/blob/master/demo/app/activity.android.ts#L24
...comment that out and the app loads (albeit w/out the lock, but no runtime errors)

This is the console from when it crashes you can see the console log\dump from the prev lines in there

JS: ** this._callback **
JS: === dump(): dumping members ===
JS: {}
JS: === dump(): dumping function and properties names ===
JS: constructor()
JS: __parent()
JS: __child()
JS: onAuthentication()
JS: onCanceled()
JS: onError()
JS: <init>()
JS: clone()
JS: equals()
JS: finalize()
JS: getClass()
JS: hashCode()
JS: notify()
JS: notifyAll()
JS: toString()
JS: wait()
JS: === dump(): finished ===
11-24 16:11:15.442  4024  4024 F art     : art/runtime/java_vm_ext.cc:410]     from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, j
ava.lang.String, int, boolean, java.lang.Object[])
11-24 16:11:15.442  4024  4024 F art     : art/runtime/java_vm_ext.cc:410]   native: #25 pc 000c8636  /data/app/org.nativescript.demo-1/lib/x86/lib
NativeScript.so (Java_com_tns_Runtime_callJSMethodNative+214)
11-24 16:11:15.442  4024  4024 F art     : art/runtime/java_vm_ext.cc:410]   native: #26 pc 0037c804  /data/app/org.nativescript.demo-1/oat/x86/bas
e.odex (java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])+200)

Guys, I updated to the lastest, re-wiped everything and I still can't get past this, can someone confirm or... anything? People in the repo are anxiously awaiting android support

@bradmartin pulled down the repo and is also getting the same results as me, thoughts?

So its a bit different in that the code you previously tested extending Application is no longer required (thanks to Auth0 I suppose)

Keep closed, I think I've found the reason for the crashing

Yeah no doesn't fix anything... Sorry I haven't checked in the new code
yet... Near total rewrite better api and in TS just haven't pushed it to git

On Dec 8, 2016 5:54 AM, "Nick Iliev" notifications@github.com wrote:

Hey @sitefinitysteve https://github.com/sitefinitysteve have you
managed to resolve your issue? I have tested your demo application and
although Google is reporting that I have successfully logged from another
device the demo itself is reloading to the auth page (not receiving the
token)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NativeScript/android-runtime/issues/546#issuecomment-265712334,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABeI6P0kN1DW4iOY2ZpZ-LOhCbnWFmigks5rF-H1gaJpZM4JzEaN
.

Was this page helpful?
0 / 5 - 0 ratings