lpradel / steam-web-api-java

:steam_locomotive: Java library to provide access to the data available from Valve's Steam API
Apache License 2.0
78 stars 16 forks source link

Android ignoring Apache HTTPClient, causing crashes. #6

Closed mapinis closed 2 years ago

mapinis commented 8 years ago

I am trying to use the API to create an application to find which of my games to play next on Android, however, when I build gradle I get these warnings:

WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages

WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages

And when I actually run, I have the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/utils/URIBuilder; at com.lukaspradel.steamapi.webapi.request.SteamWebApiRequestHandler.getRequestUri(SteamWebApiRequestHandler.java:82) at com.lukaspradel.steamapi.webapi.request.SteamWebApiRequestHandler.getRequestUrl(SteamWebApiRequestHandler.java:45) at com.lukaspradel.steamapi.webapi.request.SteamWebApiRequestHandler.getWebApiResponse(SteamWebApiRequestHandler.java:33) at com.lukaspradel.steamapi.webapi.client.SteamWebApiClient.processRequest(SteamWebApiClient.java:40) at com.markapinis.steamgamefinder.Adapter.getView(Adapter.java:47)

Adapter.java:47 is as follows: GetSchemaForGame schema = client.processRequest(request);

I have searched the internet for the last couple hours, each leading to different solutions which only cause different errors. So, I reverted back to the beginning and here I am.

Some research is pointing at the fact that Android already has an httpclient built in, and therefore ignores the Apache one that comes with the Maven (through gradle). However, I have not found any way to solve this problem.

Sorry if I have not been clear. If you need any other information, I can probably give it.

lpradel commented 8 years ago

Hi @mapinis,

from what I can tell you are correct: The version of Android you are targeting ships its own version of the Apache httpclient library so it skips this one. Which version of Android or more specifically, which SDK version you are targeting? I think I will have to throw out the Apache httpclient dependency as even Android are deprecating it. I will soon release a new version of this library that uses something like OkHttp, which should fix your problem. Thanks for bringing this Android issue to my attention.

mapinis commented 8 years ago

No problem, I am happy to help in anyway I can.

To answer your question, I am targeting API level 15 (SDK version 4.0.3) for this project.

Thank you for your response, and it is good to know that there is a possible fix.

lpradel commented 2 years ago

This issue is resolved with release 1.4