问题描述:

I trying to use this cordova background services plugin in one of my mobile Apps ( I am using the web based mobile app development platform called Appery io). I have been able to get quite a few cordova / phonegap plugins to work but when I try to add this background services plugin

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

And try to build the package I get the following error.

/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

The lines that cause the problem are ( I have numbered the lines)

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);};

}

I believe this may have something to do with a previous version of java being used as this bug seems to be similar to

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

I am a total newbie to java so if anyone could help me with some workaround or anything, it'll be great.

Thanks once again,

M&M

网友答案:

Assuming lines 711, 712, 713, 714 are the lines where you put null, you need to typecast the null to whatever type you're trying to put. Maybe you shouldn't be using null at all.

相关阅读:
Top