我正在尝试使用Nativescript Angular创建新的Android应用,构建可以通过,但是当我尝试在设备上运行它时出现错误:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{<my-app-id>/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at com.tns.Runtime.createJSInstanceNative(Native Method)
at com.tns.Runtime.createJSInstance(Runtime.java:643)
at com.tns.Runtime.initInstance(Runtime.java:618)
at com.tns.NativeScriptActivity.<init>(NativeScriptActivity.java:12)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
... 9 more
复制步骤:
cd elipay-builds
tns create MyApp --appid <my-app-id> --template ng
cd MyApp
npm install --save-dev nativescript-dev-webpack
npm install
./node_modules/.bin/update-ns-webpack --configs --deps
tns run android
tns build android --bundle
更新1:我设法弄清楚某个问题以某种方式与applicationId
有关。
更新2:如果我更新了本机脚本的id
文件中的package.json
属性:
{
...
"nativescript": {
"id": "<my-new-app-id>"
},
...
}
每次构建应用程序时,我都需要为其分配新的applicationId。这是错误的,因为商店在更新后会将我的应用识别为其他应用。
我不知道我还能尝试什么。请帮助我。
谢谢:)