iOS调试构建错误

时间:2018-03-04 20:47:19

标签: codenameone

我使用Hello World(Bare Bones)模板和Flat Blue主题创建了一个新的CodenameOne项目。我有一个简单的一类应用程序,其中start函数是:

public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Test Browser");
    hi.setLayout(new BorderLayout());
    hi.setScrollable(false);
    BrowserComponent browser = new BrowserComponent();
    browser.setURL("https://www.codenameone.com/");
    hi.addComponent(BorderLayout.CENTER, browser);
    hi.show();
}

当我发送iOS调试版本时,我收到以下错误:

[EDT] 0:0:0,19 - Exception: java.lang.NullPointerException - null
java.lang.NullPointerException
    at com.codename1.impl.javase.JavaSEPort.createBrowserComponent(JavaSEPort.java:9025)
    at com.codename1.ui.BrowserComponent.<init>(BrowserComponent.java:343)
    at com.digidava.testbrowser.TestBrowser.start(TestBrowser.java:59)
    at com.digidava.testbrowser.TestBrowserStub.run(TestBrowserStub.java:32)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1129)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:924)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
[EDT] 0:0:0,22 - Exception in TestBrowser version 1.0
[EDT] 0:0:0,23 - OS ios
[EDT] 0:0:0,23 - Error java.lang.NullPointerException
[EDT] 0:0:0,23 - Before the first form!
[EDT] 0:0:0,23 - Exception: java.lang.NullPointerException - null
java.lang.NullPointerException
    at com.codename1.impl.javase.JavaSEPort.createBrowserComponent(JavaSEPort.java:9025)
    at com.codename1.ui.BrowserComponent.<init>(BrowserComponent.java:343)
    at com.digidava.testbrowser.TestBrowser.start(TestBrowser.java:59)
    at com.digidava.testbrowser.TestBrowserStub.run(TestBrowserStub.java:32)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1129)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:924)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
[Network Thread] 0:0:1,104 - Exception: java.io.IOException - Stream closed
java.io.IOException: Stream closed
    at com.codename1.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:140)
    at com.codename1.io.BufferedInputStream.read1(BufferedInputStream.java:338)
    at com.codename1.io.BufferedInputStream.read(BufferedInputStream.java:445)
    at com.codename1.io.BufferedInputStream.read(BufferedInputStream.java:668)
    at com.codename1.io.Util.copyNoClose(Util.java:132)
    at com.codename1.io.Util.copyNoClose(Util.java:118)
    at com.codename1.io.Util.copy(Util.java:153)
    at com.codename1.io.Util.copy(Util.java:107)
    at com.codename1.io.Util.readInputStream(Util.java:202)
    at com.codename1.io.ConnectionRequest.readResponse(ConnectionRequest.java:1308)
    at com.codename1.io.ConnectionRequest.performOperation(ConnectionRequest.java:797)
    at com.codename1.io.NetworkManager$NetworkThread.run(NetworkManager.java:282)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Timeout reached.  Destroying process
Process timed out
Failed to generate device screenshot! /var/folders/p7/d3z112yd0156kxkm2p21p8ym0000gn/T/build536155541163742895xxx/res/Default.png

我做错了吗?

1 个答案:

答案 0 :(得分:0)

你看到的是splash screen process的失败。您不应将浏览器组件或本机组件(例如地图)放置为应用程序显示的第一个屏幕,如果需要,则需要提供自己的初始屏幕。

E.g:

public void start() {
    if(current != null){
        current.show();
        return;
    }

    if(!BrowserComponent.isNativeBrowserSupported()) {
        Form loading = new Form("Loading");
        loading.show();
    } else {
        Form hi = new Form("Test Browser");
        hi.setLayout(new BorderLayout());
        BrowserComponent browser = new BrowserComponent();
        browser.setURL("https://www.codenameone.com/");
        hi.addComponent(BorderLayout.CENTER, browser);
        hi.show();         
    }
}