简体   繁体   中英

codename one app doesn't build for windows

i am trying to build my app for windows phone, but codename one build server gives me build error. Here's the error log: https://s3.amazonaws.com/codenameone-build-response/7e34c6a4-f939-4044-8ab3-afbad45e7447-1450100218601-error.txt

When i build it for Android, everything's fine.

When i run my app from NetBeans, everything seems to be fine too, although console shows following red sentences:

  1. Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller code size and wider device support

  2. Note: C:\\Users\\Andrius\\Documents\\NetBeansProjects\\dogspuppiesforsaleApp\\src\\userclasses\\StateMachine.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\\Users\\Andrius\\Documents\\NetBeansProjects\\dogspuppiesforsaleApp\\src\\userclasses\\StateMachine.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

  3. Note: C:\\Users\\Andrius\\Documents\\NetBeansProjects\\dogspuppiesforsaleApp\\src\\userclasses\\StateMachine.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\\Users\\Andrius\\Documents\\NetBeansProjects\\dogspuppiesforsaleApp\\src\\userclasses\\StateMachine.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

  4. Grd 14, 2015 3:44:25 PM java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\\JavaSoft\\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

One of the codename one admins told me that Windows phone has an issue with 3d arrays. I am using JSON data in my app, so maybe the problem is here?

protected void setCategories() {
        JParser parser = new JParser("http://www.url.com/mobileApp/categories.php");
        this.resultArray = parser.returnArray();
        for (int i = 0; i < this.resultArray.length(); i++) {
            try {
                JSONObject jsonObject = this.resultArray.getJSONObject(i);
                categories.add(new Category(jsonObject.getInt("id"), jsonObject.getString("title")));
            } catch (JSONException ex) {
                Dialog.show("Error", ex.toString(), "Ok", null);
            }
        }
}

JParser class:

public class JParser {
    public ConnectionRequest r;
    public JSONArray jsonArray;
    public String url;

    public JParser(String url) {
        this.jsonArray = new JSONArray();
        this.url = url;
        this.r = new ConnectionRequest() {
            @Override
            protected void readResponse(InputStream input) throws IOException {
                JSONParser p = new JSONParser();
                Hashtable h = p.parse(new InputStreamReader(input));

                try {
                    String hashString = h.toString();
                    JSONObject entries = new JSONObject(hashString);
                    JSONArray rez = new JSONArray();
                    rez = entries.getJSONArray("root"); //musu JSON objektas visada prasides su root
                    setArray(rez);
                } catch (JSONException ex) {
                    System.out.println(ex);
                    Dialog.show("Error", ex.toString(), "Ok", null);
                }
            }
        };

        this.r.setUrl(this.url);
        this.r.setPost(false); //nieko nepostinam, tik pasiimam parsinti
        InfiniteProgress prog = new InfiniteProgress(); //nesibaigiantis procesas
        Dialog dlg = prog.showInifiniteBlocking(); //rodom dialoga su loading
        this.r.setDisposeOnCompletion(dlg); //kai baigia krauti, isjungiam
        NetworkManager.getInstance().addToQueueAndWait(this.r); //pridedam i eile
        this.r.getResponseData(); //gaunam duomenis
    }

    public void setArray(JSONArray a) {
        this.jsonArray = a;
    }

    public JSONArray returnArray() {
        return this.jsonArray;
    }
} 

I can't really tell where your error is coming from but you can rewrite your code to read response in readResponse() process json response in postResponse() and without JsonArray(), try below:

public class JParser {

public ConnectionRequest r;
public String url;

public JParser(String url) {
    this.url = url;

    InfiniteProgress prog = new InfiniteProgress();
    Dialog dlg = prog.showInifiniteBlocking();
    try {
        this.r = new ConnectionRequest() {
            Map response = null;

            @Override
            protected void readResponse(InputStream input) throws IOException {
                JSONParser parser = new JSONParser();
                response = parser.parseJSON(new InputStreamReader(input));
            }

            @Override
            protected void postResponse() {
                List responseList = (List) response.get("root");
                if (responseList != null) {
                    // save or use your response as a list here, for exampple:
                    System.out.println(responseList.toString()); // output for debug

                    // Or even loop through the result:
                    for (Object resList : responseList) {
                        Map tempHash = (Map) resList;
                        String result = tempHash.get("anElementInsideRoot").toString();
                        System.out.println(result);
                    }
                } else {
                    //It returns null value
                }
            }
        };

        this.r.setUrl(this.url);
        this.r.setPost(false);
        NetworkManager.getInstance().addToQueueAndWait(this.r);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        Dialog.show("Error", ex.getMessage(), "Ok", null);
    } finally {
        dlg.dispose();
    }
}
}

Also remove this.r.getResponseData(); it's not needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM