I'm having a problem with a Android/IOs app: the library code (libgdx?) throws a NPE, but debugging in RoboVM is not supported. When run in Android, it works as expected and reeaches the handleHttpResponse()
method. When run in IOs, it reaches the failed(Throwable t) method with t being a NullPointerException
. I've created a sample app to show the issue, maybe it's my fault, so here is the code:
public class Npe extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
loadHttps("https://www.google.it");
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
private static void loadHttps(String url) {
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl(url);
Gdx.net.sendHttpRequest(httpGet, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
String res = httpResponse.getResultAsString();
System.err.println("res = \"" + res + "\"");
}
@Override
public void failed(Throwable t) {
System.err.println("On IOs we reach this point");
t.printStackTrace(); // and t is a NPE
}
@Override
public void cancelled()
{
}
});
}
}
and my robovm.xml:
<config>
<executableName>${app.executable}</executableName>
<mainClass>${app.mainclass}</mainClass>
<os>ios</os>
<arch>thumbv7</arch>
<target>ios</target>
<iosInfoPList>Info.plist.xml</iosInfoPList>
<resources>
<resource>
<directory>../android/assets</directory>
<includes>
<include>**</include>
</includes>
<skipPngCrush>true</skipPngCrush>
</resource>
<resource>
<directory>data</directory>
</resource>
</resources>
<forceLinkClasses>
<pattern>org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl</pattern>
<pattern>com.android.org.conscrypt.JSSEProvider</pattern>
<pattern>com.android.org.conscrypt.OpenSSLProvider</pattern>
<pattern>com.android.org.conscrypt.OpenSSLSocketFactoryImpl</pattern>
<pattern>com.android.okhttp.HttpsHandler</pattern>
<pattern>com.badlogic.gdx.scenes.scene2d.ui.*</pattern>
<pattern>org.apache.harmony.xnet.provider.jsse.OpenSSLProvider</pattern>
<pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
<pattern>com.android.org.bouncycastle.jce.provider.BouncyCastleProvider</pattern>
<pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
<pattern>org.apache.harmony.xnet.provider.jsse.JSSEProvider</pattern>
<pattern>com.android.org.bouncycastle.jce.provider.JDKKeyStore</pattern>
<pattern>org.apache.harmony.security.provider.cert.X509CertFactoryImpl</pattern>
<pattern>com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi</pattern>
<pattern>org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK$MD5</pattern>
</forceLinkClasses>
<libs>
<lib>build/libs/ios/libgdx-box2d.a</lib>
<lib>build/libs/ios/libgdx-bullet.a</lib>
<lib>build/libs/ios/libgdx-freetype.a</lib>
<lib>build/libs/ios/libgdx.a</lib>
<lib>build/libs/ios/libObjectAL.a</lib>
</libs>
<frameworks>
<framework>UIKit</framework>
<framework>OpenGLES</framework>
<framework>QuartzCore</framework>
<framework>CoreGraphics</framework>
<framework>OpenAL</framework>
<framework>AudioToolbox</framework>
<framework>AVFoundation</framework>
</frameworks>
</config>