gpt4 book ai didi

android - Trigger.io barcode.scan 抛出 Java 错误

转载 作者:行者123 更新时间:2023-11-29 16:09:46 25 4
gpt4 key购买 nike

使用 Trigger.io 的 barcode api在仅包含样板 HTML 和以下 JavaScript 的应用程序中:

forge.barcode.scan(function (value) {
alert("You scanned: "+value);
});

我在日志中收到以下错误:

Forge Java error: RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

完整错误条目:

[INFO] D/Forge ( 1109): Returned: {"content":{"message":"Forge Java error: RuntimeException: Can't create handler inside thread that has not called Looper.prepare()","type":"UNEXPECTED_FAILURE","subtype":null,"full_error":"java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.(Handler.java:197) at android.os.Handler.(Handler.java:111) at android.app.Dialog.(Dialog.java:107) at android.app.AlertDialog.(AlertDialog.java:114) at android.app.AlertDialog$Builder.create(AlertDialog.java:931) at android.app.AlertDialog$Builder.show(AlertDialog.java:950) at io.trigger.forge.android.modules.barcode.API.scan(API.java:68) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at io.trigger.forge.android.core.ForgeApp.callJavaFromJavaScript(ForgeApp.java:247) at io.trigger.forge.android.core.ForgeJSBridge$1.run(ForgeJSBridge.java:17) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)\n"},"callid":"35E46BC5-1C17-4354-B09B-BE67B5FCD513","status":"error"}

更新:

下面是我的代码:

文件 config.json

{
"config_version": "2",
"name": "Scan to Web",
"author": "email@email.com",
"version": "0.1",
"platform_version": "v1.4",
"description": "An empty app created by default",
"modules": {
"logging": {
"level": "DEBUG"
},
"barcode": true,
"contact": true,
"file": true,
"is": true,
"media": true,
"prefs": true,
"request": {
"permissions": ["http://*/*", "https://*/*"]
},
"tools": true,
"reload": true
}
}

文件 default.js

forge.barcode.scan(function (value) {
alert("You scanned: "+value);
});

文件 index.html

<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
<link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/default.js"></script>
</head>
<body>

<p>Hello world!</p>

</body>
</html>

最佳答案

尝试以下两种方法之一:

1) 在您的应用配置中打开重新加载模块。我知道这听起来很奇怪或愚蠢,但相信我,它现在应该可以解决您的问题。当 Reload 关闭时,我遇到了与 Request 模块非常相似的问题。

2) 将 src/config.json 中的“platform_version”从“v1.4”更改为“v1.4.25”。我认为上一个平台版本有点损坏。

关于android - Trigger.io barcode.scan 抛出 Java 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14417989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com