Nativescript 6.0 Android 应用小部件无法正常工作
Nativescript 6.0 Android App Widget not working
我正在尝试将应用程序小部件与 NativeScript 6.0 Core 一起使用。
我使用了 Nativescript 提供的示例代码:
sample-Android-Widgets
它编译并运行良好,但是当我尝试将小部件放置在屏幕上时,出现以下错误:
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to instantiate receiver com.tns.MyWidget: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to instantiate receiver com.tns.MyWidget: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3365)
System.err: at android.app.ActivityThread.access00(ActivityThread.java:199)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
System.err: at android.os.Looper.loop(Looper.java:193)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err: at com.tns.Runtime.createJSInstanceNative(Native Method)
System.err: at com.tns.Runtime.createJSInstance(Runtime.java:778)
System.err: at com.tns.Runtime.initInstance(Runtime.java:751)
System.err: at com.tns.MyWidget.<init>(MyWidget.java:13)
System.err: at java.lang.Class.newInstance(Native Method)
System.err: at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:84)
System.err: at androidx.core.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:56)
System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3358)
System.err: ... 8 more
我将 NativeScript 更新到新的 6.0 版本后遇到了问题。
非常感谢任何帮助,谢谢!
谢谢马诺杰!
我想通了!我在 webpack 配置中接近答案,但不知道在 appComponents
.
中插入什么样的路径
这份文件对我很有帮助Extend Application Activity
这是我在 webpack.config
中编辑的内容
const appComponents = [
...
resolve(__dirname, "app/<MyFile>.js"),
];
再次感谢!
我正在尝试将应用程序小部件与 NativeScript 6.0 Core 一起使用。 我使用了 Nativescript 提供的示例代码: sample-Android-Widgets
它编译并运行良好,但是当我尝试将小部件放置在屏幕上时,出现以下错误:
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to instantiate receiver com.tns.MyWidget: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to instantiate receiver com.tns.MyWidget: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3365)
System.err: at android.app.ActivityThread.access00(ActivityThread.java:199)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
System.err: at android.os.Looper.loop(Looper.java:193)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/MyWidget'
System.err: at com.tns.Runtime.createJSInstanceNative(Native Method)
System.err: at com.tns.Runtime.createJSInstance(Runtime.java:778)
System.err: at com.tns.Runtime.initInstance(Runtime.java:751)
System.err: at com.tns.MyWidget.<init>(MyWidget.java:13)
System.err: at java.lang.Class.newInstance(Native Method)
System.err: at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:84)
System.err: at androidx.core.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:56)
System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3358)
System.err: ... 8 more
我将 NativeScript 更新到新的 6.0 版本后遇到了问题。
非常感谢任何帮助,谢谢!
谢谢马诺杰!
我想通了!我在 webpack 配置中接近答案,但不知道在 appComponents
.
这份文件对我很有帮助Extend Application Activity
这是我在 webpack.config
const appComponents = [
...
resolve(__dirname, "app/<MyFile>.js"),
];
再次感谢!