user2641733
user2641733

Reputation: 25

IBM Watson Visual Recognition return empty result in Java android?

Hi i'm reading all the sources that provides help to using the service however i have this line of debug says :

I/CredentialUtils: JNDI string lookups is not available.

compile with compile 'com.ibm.watson.developer_cloud:java-sdk:3.0.1'

VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_19);
service.setApiKey("<api_key>");
ClassifyImagesOptions options = new ClassifyImagesOptions.Builder().images(currentSelectFileLocation).build();
 VisualClassification result = service.classify(options).execute();
System.out.println(result);

Upvotes: 0

Views: 341

Answers (1)

Leonardo Kenji Shikida
Leonardo Kenji Shikida

Reputation: 751

the error you're getting does not come from the IBM Watson Visual Recognition Bluemix service, but from the Watson Java SDK library you're using.

see

https://github.com/watson-developer-cloud/java-sdk/search?utf8=%E2%9C%93&q=javax.naming

When you deploy some java code inside bluemix, in a liberty container, it can use JNDI to get the service credentials from inside bluemix. But when you run from outside bluemix, of course, you must provide the credentials (in your case, in your android app) in order to access the service.

It seems that for some reason your android app is importing javax.naming.Context and then the SDK is getting a little bit confusing.

You have these options here IMO

  1. remove the javax.naming.Context from your android project
  2. download and recompile the SDK code to fix that

Notice that providing your credentials in the android app is probably not a good idea, so I'd suggest you to take a different path here. Create a RESTful web service at Bluemix that wraps the calls to the Watson service. Of course, you may want to secure this access, because every call to the Watson service will be billed in your bluemix account.

Upvotes: 1

Related Questions