I am trying to use cloudsight.ai api in my android app using image from url, The cloudsight.ai api from mashape platform
When I built the app there is no problem but when I run it and click the button it crashed.
Here is the code of request using unirest library:
try {
HttpResponse<JsonNode> sent = Unirest.post("https://camfind.p.mashape.com/image_requests")
.header("X-Mashape-Key", "key")
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Accept", "application/json")
.field("image_request[language]", "en")
.field("image_request[locale]", "en_US")
.field("image_request[remote_image_url]", img)
.asJson();
req_body=sent.getBody().toString();
} catch (UnirestException e) {
}
And here the code of response :
try {
JSONObject json = new JSONObject(req_body);
token = json.getString("token");
} catch (JSONException e) {
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
String res_path = "https://camfind.p.mashape.com/image_responses/" + token;
try {
HttpResponse<JsonNode> response = Unirest
.get(res_path)
.header("X-Mashape-Key", "key")
.header("Accept", "application/json")
.asJson();
result=response.getBody().toString();
} catch (UnirestException e) {
}
Toast.makeText(Main3Activity.this,result,Toast.LENGTH_SHORT).show();
}
How to solve this problem?
NoSuchFieldError
is thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. Most often it occurs when your application hasn't fully compile or when you compiled OK but later made changes to some references that haven't been compile.You can fix this by cleaning all your project files and rebuilding them again from scratch using the clean and build menu items.