2.1.4-rc3 - Not Working on Android
See original GitHub issueClient logs:
java.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Lorg/apache/http/entity/ContentType;)V in class Lorg/apache/http/entity/StringEntity; or its super classes (declaration of 'org.apache.http.entity.StringEntity'
Location of this issue: https://github.com/tomakehurst/wiremock/blob/2.0-beta/src/main/java/com/github/tomakehurst/wiremock/client/HttpAdminClient.java
Line 232:
private String postJsonAssertOkAndReturnBody(String url, String json, int expectedStatus) {
...
StringEntity stringEntity = new StringEntity(json, APPLICATION_JSON);
post.setEntity(stringEntity);
...
}
That StringEntity constructor is not supported on the Apache HTTP Client on Android. Please refer to a previous PR which fixed this to allow support on Android - https://github.com/tomakehurst/wiremock/pull/330/files
Usable on Android:
StringEntity stringEntity = new StringEntity(json);
stringEntity.setContentType(APPLICATION_JSON.getMimeType());
post.setEntity(stringEntity);
This should be updated and documented on why this method signature is used. It looks like this slipped back in as it’s the more concise way to write it. Also, if there are any other usages of this constructor, those should be updated to use this as well.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
android - gradle - iTecNote
and started getting this error. I tried to clean and rebuild the project but it didn't work. Reverting back to alpha05 version is...
Read more >Nook HD, HD+ Android Development | Page 2 - XDA Forums
Android development for the Nook HD, HD+.
Read more >Top 5 Ways to Fix 'Your Device Isn't Compatible with This ...
1. Update Android OS. It's the first thing you should do when you face the 'your device isn't compatible with this version' error...
Read more >Changelog - NoScript: block scripts and own your browser!
The NoScript Security Suite is a free extensions for Firefox, Chrome and other browsers, preemptively blocks malicious scripts and allows JavaScript and ...
Read more >3.4 Milestone - GitHub
LineEdit on Android with Hacker's Keyboard ignores or behaves weird on arrow ... "Audio Mic Record Demo" not working on Godot 3.4 archived ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah good, glad it works for you too.
I got it to work by switching to a constructor that took the charset as a String. It is deprecated in the current version of HTTPClient, but still present so I guess it had been around since since the 4.0 version Android provides by default.
Thanks for the explanation, sounds great! I updated my examples project (https://github.com/handstandsam/AndroidHttpMockingExamples) to use 2.1.5-rc4 and it’s working great. I’m closing this as it’s now working 👍