gpt4 book ai didi

java - 错误 : reference to put is ambiguous, JSONObject 中的方法 put(String,Collection) 和 JSONObject 中的方法 put(String,Map) 匹配

转载 作者:行者123 更新时间:2023-12-01 11:43:57 25 4
gpt4 key购买 nike

我尝试在我的一个移动应用程序中使用这个cordova后台服务插件(我正在使用名为Appery io的基于网络的移动应用程序开发平台)。我已经能够让相当多的 cordova/phonegap 插件正常工作,但是当我尝试添加这个后台服务插件时

https://github.com/Red-Folder/bgs-core

并尝试构建包,但出现以下错误。

/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java:[711,16] error: reference to put is ambiguous, both method put(String,Collection) in JSONObject and method put(String,Map) in JSONObject match

/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java:[712,16] error: reference to put is ambiguous, both method put(String,Collection) in JSONObject and method put(String,Map) in JSONObject match

/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java:[713,16] error: reference to put is ambiguous, both method put(String,Collection) in JSONObject and method put(String,Map) in JSONObject match

/src/com/red_folder/phonegap/plugin/backgroundservice/BackgroundServicePluginLogic.java:[714,16] error: reference to put is ambiguous, both method put(String,Collection) in JSONObject and method put(String,Map) in JSONObject match

导致问题的行是(我已经对行进行了编号)
if (this.mServiceConnected != null && this.mServiceConnected && this.isServiceRunning()) {
尝试 { result.put("ServiceRunning", true); } catch (Exception ex) {Log.d(LOCALTAG, "将 ServiceRunning 添加到 JSONObject 失败", ex);};
尝试 { result.put("TimerEnabled", isTimerEnabled()); } catch (Exception ex) {Log.d(LOCALTAG, "将 TimerEnabled 添加到 JSONObject 失败", ex);};
尝试 { result.put("配置", getConfiguration()); } catch (Exception ex) {Log.d(LOCALTAG, "向 JSONObject 添加配置失败", ex);};
尝试 { result.put("LatestResult", getLatestResult()); } catch (Exception ex) {Log.d(LOCALTAG, "将最新结果添加到 JSONObject 失败", ex);};
尝试 { result.put("TimerMilliseconds", getTimerMilliseconds()); } catch (Exception ex) {Log.d(LOCALTAG, "向 JSONObject 添加 TimerMilliseconds 失败", ex);};
} 别的 {
710. 尝试 { result.put("ServiceRunning", false); } catch (Exception ex) {Log.d(LOCALTAG, "将 ServiceRunning 添加到 JSONObject 失败", ex);};
711. 尝试 { result.put("TimerEnabled", null); } catch (Exception ex) {Log.d(LOCALTAG, "将 TimerEnabled 添加到 JSONObject 失败", ex);};
712. try { result.put("配置", null); } catch (Exception ex) {Log.d(LOCALTAG, "向 JSONObject 添加配置失败", ex);};
713. 尝试{ result.put("LatestResult", null); } catch (Exception ex) {Log.d(LOCALTAG, "将最新结果添加到 JSONObject 失败", ex);};
714. 尝试 { result.put("TimerMilliseconds", null); } catch (Exception ex) {Log.d(LOCALTAG, "向 JSONObject 添加 TimerMilliseconds 失败", ex);};
}

我相信这可能与使用以前版本的java有关,因为这个错误似乎类似于

http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6199075

我是java的新手,所以如果有人可以帮助我解决一些解决方法或任何事情,那就太好了。

再次感谢,巧克力 bean

最佳答案

假设第 711、712、713、714 行是您放置 null 的行,您需要将 null 类型转换为您尝试放置的任何类型。也许您根本不应该使用 null

关于java - 错误 : reference to put is ambiguous, JSONObject 中的方法 put(String,Collection) 和 JSONObject 中的方法 put(String,Map) 匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29313439/

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