Trying to give RoboVM a try

108 views
Skip to first unread message

Marco Antônio Lopes da Silva

unread,
Nov 20, 2015, 5:50:00 AM11/20/15
to RoboVM
Hello,

We are developing apps for Android and iOS for some years. Last night I decided to give RoboVM a try because it was very promising. Well, I installed the RoboVM Studio and things were not so smooth like the presentation video. A lot of errors while trying to compile for iOS. Sometimes UIViewController.class was not found in ios.jar and now without changing anything on my code I am getting:

[ERROR] Couldn't compile app
java.util.zip.ZipException: invalid stored block lengths

The app simple does not compile anymore, for iOS. So, I think that the idea is fantastic, but there is still a way for this to become a real tool for production. I have my fingers crossed for this project to become reality.

Regards,

Marco Antonio
Director
Dzign-e

Niklas Therning

unread,
Nov 21, 2015, 1:20:36 AM11/21/15
to Marco Antônio Lopes da Silva, RoboVM
Something has gone really wrong with your set up it seems. Can you provide us with some details? We'd love to see all those errors and your idea.log file. Please see http://docs.robovm.com/errors.html for info on how to get the logs and other diagnostics.

--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Marco Antônio Lopes da Silva

unread,
Nov 21, 2015, 5:17:27 AM11/21/15
to RoboVM, marcoan...@gmail.com
Hello Niklas,

Yesterday I restart my computer and now I am able to compile the for iOS. It is working.

I am trying to migrate an API we already have developed for Android and iOS to RoboVM. We use this API in all our projects. Today I tried to run a simple HTTPS request that is part of our API.  On iOS I am getting a Null Pointer Exception when I try to send data to the server:

java.lang.NullPointerException
at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:94)
at com.android.okhttp.Connection.upgradeToTls(Connection.java:132)
at com.android.okhttp.Connection.connect(Connection.java:107)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254)
at com.dzigne.myapp.ServerAPI.getJSONString(ServerAPI.java:181)
at com.dzigne.myapp.ServerAPI.startQuery(ServerAPI.java:415)
at com.dzigne.myapp.ServerAPI.run(ServerAPI.java:376)
at java.lang.Thread.run(Thread.java:837)

The method that is triggering the exception is below. I would appreciate if you take a look on it and give some suggestions on how to solve this. 

Thanks a lot,

Marco Antonio
Director
Dzign-e

public String getJSONString(String url, String params, String user, String pass) throws IOException {

    URL url0
;
   
HttpsURLConnection urlConn;
   
DataOutputStream printout;
   
BufferedReader input;

    url0
= new URL(url);

    urlConn
= getConnection(url0, user, pass);

// THIS IS THE LINE THAT IS TRIGGERING THE NULL POINTER EXCEPTION (I checked and urlConn is nor NULL)
   
OutputStream outPutStream = urlConn.getOutputStream();

    printout
= new DataOutputStream(outPutStream);

    printout
.writeBytes(params);
    printout
.flush();
    printout
.close();

    input
= new BufferedReader(new InputStreamReader(urlConn.getInputStream()));

   
String str;
   
StringBuilder json = new StringBuilder("");

   
while ((str = input.readLine()) != null) {

        json
.append(str);

   
}

    input
.close();

    urlConn
.disconnect();

   
return json.toString();

}


Marco Antônio Lopes da Silva

unread,
Nov 21, 2015, 5:30:00 AM11/21/15
to RoboVM, marcoan...@gmail.com
Hi, 

I forgot to mention that the method is working fine when I run on Android.

Regards,

Marco Antonio
Director
Dzign-e

Niklas Therning

unread,
Nov 21, 2015, 8:04:06 AM11/21/15
to Marco Antônio Lopes da Silva, RoboVM
You need to force link a couple of classes in your robovm.xml file to make URLConnection work as expected with HTTP(S). Please see this sample for an example: https://github.com/robovm/robovm-store-app/blob/master/ios/robovm.xml

Docs for <forceLinkClasses> can be found at http://docs.robovm.com/configuration.html#forcelinkclasses.

RoboVM tries to be smart and only compile in the classes actually needed by your app. The way it does this is to start at the main class and compile its dependencies. It then continues with the dependencies of those dependencies and so on. This is done to decrease compile times and app size. The problem with this is that it breaks reflection. So if your app relies on reflection you may have to give the RoboVM compiler hints via <forceLinkClasses> on which classes it must include in the app. Unfortunately URLConnection in Android's runtime lib (which is what we use in RoboVM) relies on reflection to load the HTTP/HTTPS implementations. This is why you need to use <forceLinkClasses> to make them work.

Marco Antônio Lopes da Silva

unread,
Nov 21, 2015, 8:42:32 AM11/21/15
to RoboVM, marcoan...@gmail.com
Thanks, Niklas. It worked like a charm. I had already placed some of those forceLinkClasses but some others were not there. I will keep doing some tests during my trial period. We are considering the possibility of shifting our next projects to RoboVM.

Regards,

Marco Antonio
Director
Dzign-e

Marco Antônio Lopes da Silva

unread,
Nov 21, 2015, 9:01:15 AM11/21/15
to RoboVM, marcoan...@gmail.com
Hello,

I am getting this error every time I change something on my code. So I close the RoboVM Studio and start it again and I am able to compile. Using RoboVM 1.9.

Regards,

Marco
Director
Dzign-e

[ERROR] Couldn't compile app
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:418)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:656)
at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:635)
at org.robovm.compiler.plugin.objc.InterfaceBuilderClassesPlugin.getCustomClass(InterfaceBuilderClassesPlugin.java:250)
at org.robovm.compiler.plugin.objc.InterfaceBuilderClassesPlugin.beforeConfig(InterfaceBuilderClassesPlugin.java:144)
at org.robovm.compiler.config.Config$Builder.build(Config.java:1493)
at org.robovm.idea.compilation.RoboVmCompileTask.compileForRunConfiguration(RoboVmCompileTask.java:210)
at org.robovm.idea.compilation.RoboVmCompileTask.execute(RoboVmCompileTask.java:78)
at com.intellij.compiler.impl.CompileDriver.executeCompileTasks(CompileDriver.java:627)
at com.intellij.compiler.impl.CompileDriver.access$400(CompileDriver.java:88)
at com.intellij.compiler.impl.CompileDriver$3.run(CompileDriver.java:410)
at com.intellij.compiler.progress.CompilerTask.run(CompilerTask.java:196)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:367)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)

Mario Zechner

unread,
Nov 22, 2015, 3:38:10 AM11/22/15
to RoboVM, marcoan...@gmail.com
 Did you create your project in a folder with wonky permissions? What build system are you using (Maven/Gradle/none)?
Reply all
Reply to author
Forward
0 new messages