weex picker.pick 报错

用vue写的代码,在android下一点击选择按钮就报错,程序退出
日志如下

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                                                                     at com.taobao.weex.bridge.NativeInvokeHelper$1.run(NativeInvokeHelper.java:236)
                                                                     at com.taobao.weex.common.WXThread$SafeRunnable.run(WXThread.java:235)
                                                                     at android.os.Handler.handleCallback(Handler.java:761)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                     at android.os.Looper.loop(Looper.java:156)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:6524)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
                                                                  Caused by: java.lang.reflect.InvocationTargetException
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.taobao.weex.bridge.MethodInvoker.invoke(MethodInvoker.java:232)
                                                                     at com.taobao.weex.bridge.NativeInvokeHelper$1.run(NativeInvokeHelper.java:234)
                                                                     at com.taobao.weex.common.WXThread$SafeRunnable.run(WXThread.java:235) 
                                                                     at android.os.Handler.handleCallback(Handler.java:761) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:98) 
                                                                     at android.os.Looper.loop(Looper.java:156) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:6524) 
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) 
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831) 
                                                                  Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
                                                                     at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:255)
                                                                     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2187)
                                                                     at android.content.res.Resources.getLayout(Resources.java:1178)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
                                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                                     at android.support.v7.app.AlertController$AlertParams.createListView(AlertController.java:877)
                                                                     at android.support.v7.app.AlertController$AlertParams.apply(AlertController.java:854)
                                                                     at android.support.v7.app.AlertDialog$Builder.create(AlertDialog.java:883)
                                                                     at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:901)
                                                                     at com.taobao.weex.appfram.pickers.WXPickersModule.performSinglePick(WXPickersModule.java:364)
                                                                     at com.taobao.weex.appfram.pickers.WXPickersModule.pick(WXPickersModule.java:247)
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at com.taobao.weex.bridge.MethodInvoker.invoke(MethodInvoker.java:232) 
                                                                     at com.taobao.weex.bridge.NativeInvokeHelper$1.run(NativeInvokeHelper.java:234) 
                                                                     at com.taobao.weex.common.WXThread$SafeRunnable.run(WXThread.java:235) 
                                                                     at android.os.Handler.handleCallback(Handler.java:761) 
                                                                     at android.os.Handler.dispatchMessage(Handler.java:98) 
                                                                     at android.os.Looper.loop(Looper.java:156) 
                                                                     at android.app.ActivityThread.main(ActivityThread.java:6524) 
                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) 
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

demo代码

props: {
        value: {
            default: ''
        },
        index: {
            default: 0
        },
        txtChange: {
            default: ''
        }
    },
    methods: {
        pick: function () {
            var picker = weex.requireModule('picker');
            var items = new Array("Saab", "Volvo", "BMW");
            var self = this;
            picker.pick({
                'items': items,
                'index': self.index
            }, function (ret) {
                var result = ret.result;
                if (result == 'success') {
                    self.value = items[ret.data];
                    self.index = ret.data;
                }
            });
        },
    }

回答:

哇哈哈哈,在客户打死我的最后一刻,我解决了这个 bug…

weex toolkit 是个大坑

--- a/platforms/android/app/src/main/AndroidManifest.xml
+++ b/platforms/android/app/src/main/AndroidManifest.xml
@@ -46,7 +46,8 @@
                 android:name=".WXPageActivity"
                 android:label="@string/app_name"
                 android:screenOrientation="portrait"
-                android:theme="@android:style/Theme.NoTitleBar">
+                android:theme="@style/AppTheme.NoActionBar">

————— 以下为之前发的 log —————

同样的问题,官方敢不敢出来看看

07-05 16:32:45.814 18406-18459/com.zljy.patient D/weex: callJS >>>> instanceId:1function:callJS tasks:[{"data":"1","type":2},{"data":"[{\"args\":[\"98\",\"click\",{\"position\":{\"height\":96.875,\"width\":280.20834,\"x\":234.375,\"y\":666.6667}},null],\"method\":\"fireEvent\"}]","type":3}]
07-05 16:32:45.824 18406-18459/com.zljy.patient D/weex: [WXBridgeManager] callNativeModule >>>> instanceId:1, module:picker, method:pick, arguments:[{"index":0,"items":["Saab","Volvo","BMW"]},"41"]
07-05 16:32:45.834 18406-18406/com.zljy.patient W/ResourceType: No package identifier when getting value for resource number 0x00000000
07-05 16:32:45.834 18406-18406/com.zljy.patient W/System.err: android.content.res.Resources$NotFoundException: Resource ID #0x0
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.content.res.Resources.getValue(Resources.java:1147)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2350)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.content.res.Resources.getLayout(Resources.java:963)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.support.v7.app.AlertController$AlertParams.createListView(AlertController.java:877)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.support.v7.app.AlertController$AlertParams.apply(AlertController.java:854)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.support.v7.app.AlertDialog$Builder.create(AlertDialog.java:883)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.taobao.weex.appfram.pickers.WXPickersModule.performSinglePick(WXPickersModule.java:229)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.taobao.weex.appfram.pickers.WXPickersModule.pick(WXPickersModule.java:85)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at java.lang.reflect.Method.invoke(Method.java:525)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.taobao.weex.bridge.MethodInvoker.invoke(MethodInvoker.java:46)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.taobao.weex.bridge.NativeInvokeHelper$1.run(NativeInvokeHelper.java:48)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.taobao.weex.common.WXThread$SafeRunnable.run(WXThread.java:49)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.os.Handler.handleCallback(Handler.java:730)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:92)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.os.Looper.loop(Looper.java:137)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5473)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at java.lang.reflect.Method.invoke(Method.java:525)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
07-05 16:32:45.844 18406-18406/com.zljy.patient W/System.err:     at dalvik.system.NativeStart.main(Native Method)

回答:

楼主解决问题了没?我这也碰到了这个问题,不知道怎么解决。。。

回答:

请提供你的当前开发环境

            pickTime () {
                const picker = weex.requireModule('picker')

                var items = new Array("Saab", "Volvo", "BMW");
                picker.pick({
                    'index': 1,
                    'items': items
                }, event => {
                    if (event.result === 'success') {
                        this.value = event.data
                    }
                })
            }

运行正常
Android:7.1.2
weex_sdk:0.13.0

回答:

activity 主题 设置Theme.AppCompat.Light.DarkActionBar

暂无评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注