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 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 by mistkibl (63 points)
edited Jun 20 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 by Vishnu Garg (674 points)
Hi, I am able to make API calls using App42 Java SDK in android, Please find the dropbox basic sample link.
https://www.dropbox.com/s/fqlc11rpy3g8s0z/AppWarp_App42_libgdxSample.zip?dl=0.
Thank you but, as long as your call does not include a function which is specific to apache http client 4.1. it will work. But try to make a call like scoreBoardService.getTopNRankers(gameName, NUM_SCORES). It will use EntityUtils.consume() which is specific to 4.1. and it will crash...
Please use App42 Android SDK to build Android application through libgdx as Android System are conflicting the library used by Java SDK.
You can down load the same from below.
https://github.com/shephertz/App42_ANDROID_SDK.

Please replace the jar file and do initialize  Android SDK in Android launcher.
I got it to run! So, here is the workaround:

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.
You can use this solution as well. Let me know in case of more queries are there.
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
...