LigbGDX Problems with App42

+1 vote

Hello!

 

I am using App42 Java SDK 2.7 and LibGDX 1.9.8

 

On Desktop everything works fine, but I get the following error on Android:

 

java.lang.NoSuchMethodError: No static method consume(Lorg/apache/http/HttpEntity;)V in class Lorg/apache/http/util/EntityUtils; or its super classes (declaration of 'org.apache.http.util.EntityUtils' appears in /system/framework/org.apache.http.legacy.boot.jar)

at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.executeGet(RESTConnectorAsync.java:97)

at com.shephertz.app42.paas.sdk.java.game.ScoreBoardService.getTopNRankers(ScoreBoardService.java:998)

at com.company.game..util.OnlineServer.loadLeaderBoard(OnlineServer.java:566)

 

 

Can anyone help me with this problem? I really like App42 and it would be a perfect addition to libGDX!

 

Thanks!

asked Jun 17, 2018 in Android by mistkibl (63 points)

2 Answers

+1 vote
 
Best answer

I got it to run! So, here is the workaround:


Use JarJar https://github.com/shevek/jarjar and rename:
 

rule org.apache.http.** org.apache.myhttp.@1
rule org.json.** org.myjson.@1


apply this to all jar files:

App42_JAVA_SDK_2.7.jar
App42MultiPlayerGamingSDK.jar
commons-logging-1.1.1.jar
httpclient-4.1.jar
httpcore-4.1.jar
json-org.jar

Add the refactored jar files to your project libs folder.

 

For IOS Moe also include in proguad:

-keep class org.apache.commons.logging.impl.NoOpLog { *; }

 

and set:

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");

 

 

answered Jun 19, 2018 by mistkibl (63 points)
edited Jun 20, 2018 by mistkibl
0 votes

Hi Mistkibi,

Greetings from ShepHertz!!!!!!!!

As you are builidng the same project on Android, you are getting such error because Android System itself contains the Apache Http library.

Please finf the soluction below to build the same on Android.

  1. Either Use App42 Android SDK in place of Java.
  2. Remove other Apache librarries when youa re building the same with Android platform.

Let me know if it helps.

 

Thanks

Vishnu Garg

App42 Team

answered Jun 18, 2018 by Vishnu Garg (674 points)
It fails on iOS robovm with the following exceptions when I tried to link user Facebook account.

Loading class 'java.util.logging.ConsoleHandler' failed
java.lang.ClassNotFoundException: java.util.logging.ConsoleHandler
Exception :com.shephertz.app42.paas.sdk.java.App42Exception: java.lang.NullPointerException.

How can I resolve this problem?
I need your urgent assistance please.
Do yourself a favour and switch to something else. Even if you get this mess here to run, in the end, the service does not scale in performance, flexibility and price. I was there years ago, take this advice and search for something else. I am happy with Google-Flexible-Environment and Websockets now.
@mistkibl thank you. It is a pity that Shephertz intentionally refused to fix and refactor the Java sdk to work well on cross-platform frameworks since they are aware of this problem.
I will leave as soon as I found something better that can scale well on the major platforms.
Can you kindly recommend a better baaS that is cross platform oriented which can fit well on Libgdx?
Yes, LibGDX is more or less dead. If your games is a simple 2D game (board, card game) with lots of UI I would strongly recommend Flutter. If you want to make a 3D game or a 2D game with lots of effects and animations take Unity. As Server, you can check out Photon.
Finally I got it to work on iOS robovm using @mistkibl's solution.

Use JarJar https://github.com/shevek/jarjar and rename:

rule org.apache.** org.myapache.@1
rule org.json.** org.myjson.@1

apply this to all jar files:

App42_JAVA_SDK_2.7.jar
App42MultiPlayerGamingSDK.jar
commons-logging-1.1.1.jar
httpclient-4.1.jar
httpcore-4.1.jar
json-org.jar

Add the refactored jar files to your project libs folder
and finally add these to your robovm.xml

<forceLinkClasses>

<pattern>com.shephertz.app42.**</pattern>
<pattern>java.util.logging.ConsoleHandler</pattern>
<pattern>java.util.logging.SimpleFormatter</pattern>
<pattern>org.myapache.**</pattern>
<pattern>org.myjson.**</pattern>

</forceLinkClasses>

Alternatively download the already modified Ap42SDks here https://tonielrosoft.com/modifiedApp42SDKs/WorkingApp42SDKs.zip
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...