我尝试在我的一个移动应用程序中使用此cordova后台服务插件(我正在使用名为Appery io的基于Web的移动应用程序开发平台)。我已经能够获得相当多的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()) {
try { result.put("ServiceRunning", true); } catch (Exception ex) {Log.d(LOCALTAG, "Adding ServiceRunning to JSONObject failed", ex);};
try { result.put("TimerEnabled", isTimerEnabled()); } catch (Exception ex) {Log.d(LOCALTAG, "Adding TimerEnabled to JSONObject failed", ex);};
try { result.put("Configuration", getConfiguration()); } catch (Exception ex) {Log.d(LOCALTAG, "Adding Configuration to JSONObject failed", ex);};
try { result.put("LatestResult", getLatestResult()); } catch (Exception ex) {Log.d(LOCALTAG, "Adding LatestResult to JSONObject failed", ex);};
try { result.put("TimerMilliseconds", getTimerMilliseconds()); } catch (Exception ex) {Log.d(LOCALTAG, "Adding TimerMilliseconds to JSONObject failed", ex);};
} else {
710. try { result.put("ServiceRunning", false); } catch (Exception ex) {Log.d(LOCALTAG, "Adding ServiceRunning to JSONObject failed", ex);};
711. try { result.put("TimerEnabled", null); } catch (Exception ex) {Log.d(LOCALTAG, "Adding TimerEnabled to JSONObject failed", ex);};
712. try { result.put("Configuration", null); } catch (Exception ex) {Log.d(LOCALTAG, "Adding Configuration to JSONObject failed", ex);};
713. try { result.put("LatestResult", null); } catch (Exception ex) {Log.d(LOCALTAG, "Adding LatestResult to JSONObject failed", ex);};
714. try { result.put("TimerMilliseconds", null); } catch (Exception ex) {Log.d(LOCALTAG, "Adding TimerMilliseconds to JSONObject failed", ex);};
}
我认为这可能与之前使用的java版本有关,因为这个bug似乎与
相似http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6199075
我是java的新手,所以如果有人可以帮我解决一些问题,那么它会很棒。
再次感谢, M&安培; M
答案 0 :(得分:1)
假设第711,712行,第713行,第714行是您放置null
的行,您需要将null
类型转换为您尝试放置的任何类型。也许你根本不应该使用null
。