NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
519 stars 135 forks source link

Building on my Xiaomi device logs error #1753

Closed guillemc23 closed 1 year ago

guillemc23 commented 1 year ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug

Building a project using my real device (Xiaomi Redmi 9) produces this output in the console. Everything works as expected but still, this error is logged in the console as soon as the app boots.


System.err: org.json.JSONException: No value for merlinnfc
  System.err:   at org.json.JSONObject.get(JSONObject.java:398)
  System.err:   at org.json.JSONObject.getJSONObject(JSONObject.java:618)
  System.err:   at android.util.MiuiMultiWindowUtils.initFreeFormResolutionArgsOfDevice(MiuiMultiWindowUtils.java:1433)
  System.err:   at android.util.MiuiMultiWindowUtils.initFreeFormResolutionArgs(MiuiMultiWindowUtils.java:1427)
  System.err:   at android.util.MiuiMultiWindowUtils.<clinit>(MiuiMultiWindowUtils.java:209)
  System.err:   at android.util.MiuiMultiWindowUtils.isSupportMultiSwitchFeature(MiuiMultiWindowUtils.java:3337)
  System.err:   at com.android.internal.policy.DecorViewMultiWinStubImpl.<init>(DecorViewMultiWinStubImpl.java:19)
  System.err:   at com.android.internal.policy.DecorViewMultiWinStubImpl$Provider.provideNewInstance(DecorViewMultiWinStubImpl$Provider.java:14)
  System.err:   at com.android.internal.policy.DecorViewMultiWinStubImpl$Provider.provideNewInstance(DecorViewMultiWinStubImpl$Provider.java:8)
  System.err:   at com.miui.base.MiuiStubRegistry.get(MiuiStubRegistry.java:129)
  System.err:   at com.miui.base.MiuiStubUtil.newInstance(MiuiStubUtil.java:77)
  System.err:   at com.android.internal.policy.DecorViewMultiWinStub.newInstance(DecorViewMultiWinStub.java:11)
  System.err:   at com.android.internal.policy.DecorView.<init>(DecorView.java:335)
  System.err:   at com.android.internal.policy.PhoneWindow.generateDecor(PhoneWindow.java:2380)
  System.err:   at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2760)
  System.err:   at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2140)
  System.err:   at com.tns.Runtime.callJSMethodNative(Native Method)
  System.err:   at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
  System.err:   at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1175)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1153)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1149)
  System.err:   at com.tns.gen.android.app.Application_ActivityLifecycleCallbacks.onActivityCreated(Application_ActivityLifecycleCallbacks.java:20)
  System.err:   at android.app.Application.dispatchActivityCreated(Application.java:355)
  System.err:   at android.app.Activity.dispatchActivityCreated(Activity.java:1373)
  System.err:   at android.app.Activity.onCreate(Activity.java:1646)
  System.err:   at androidx.core.app.ComponentActivity.onCreate(ComponentActivity.java:86)
  System.err:   at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:353)
  System.err:   at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:217)
  System.err:   at com.tns.Runtime.callJSMethodNative(Native Method)
  System.err:   at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
  System.err:   at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1175)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1153)
  System.err:   at com.tns.Runtime.callJSMethod(Runtime.java:1149)
  System.err:   at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:57)
  System.err:   at android.app.Activity.performCreate(Activity.java:8163)
  System.err:   at android.app.Activity.performCreate(Activity.java:8130)
  System.err:   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
  System.err:   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3753)
  System.err:   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3947)
  System.err:   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:106)
  System.err:   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
  System.err:   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
  System.err:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2325)
  System.err:   at android.os.Handler.dispatchMessage(Handler.java:106)
  System.err:   at android.os.Looper.loopOnce(Looper.java:210)
  System.err:   at android.os.Looper.loop(Looper.java:299)
  System.err:   at android.app.ActivityThread.main(ActivityThread.java:8280)
  System.err:   at java.lang.reflect.Method.invoke(Native Method)
  System.err:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
  System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)

To Reproduce Building any project using my device produces this issue

Expected behavior

Sample project Any project

rigor789 commented 1 year ago

Is your device using the official MIUI rom? The stack trace seems to indicate a custom firmware. If the app works, then it's probably fine? The error isn't thrown my NativeScript.

guillemc23 commented 1 year ago

Hello @rigor789!

Yes, I'm using the official MIUI rom, I haven't installed anything custom or become root in this device. The app works, it's just annoying, but I'm not sure if it can cause other kinds of issues. I reported just in case it has something to do with this other issue: https://github.com/NativeScript/plugins/issues/475

rigor789 commented 1 year ago

I'd say the two are unrelated. This issue you can check with a new app as well:

ns create testapp --ts

and then run it on the same device. If it still shows up, then it's certainly fine to ignore.

My guess is that MIUI's custom code checks for some json flags and if it fails, they print/log the stack trace - which shows up because it contains the {N} activity - but the error itself is in MiuiMultiWindowUtils... But since it's most likely just a ex.printStackTrace() call - I'm 99% sure it's fine to just ignore.

I also have a Xiaomi phone, but have never seen anything like that - I guess it's something in the newer MIUI versions (I'm on 12.5.1).

guillemc23 commented 1 year ago

Now that you mention it, I recall it started appearing once I updated to MIUI 13 🤔

Thanks for your explanation, I'm a bit lost in this part of the process 😵‍💫 We'll asume it's safe to ignore!