简体   繁体   中英

The import com.wordnik cannot be resolved

I'm very new to Android apps, and am learning as I go. So, please be specific if you give an answer.

I build a simple Android test app using eclipse Juno ADT. It works beautifully! So the next step was to add a call to the WordNik API.

I installed the WordNik Java API which installed the following libraries:

target>wordnik-java-client-1.0.0.jar

target>wordnik-java-client-1.0.0-tests.jar

target>lib>jackson-annotation-2.1.4.jar

target>lib>... 7 more jar files

I added the libraries to the Build Path via Project > Properties > Add External Jars

Now, when the add the import to my code:

import com.wordnik.client.api.*;
import com.wordnik.client.model.*;

I get errors "The import com.wordnik cannot be resolved.

I have tried recommendations I've seen for other such errors such as

Project > clean

Double checking my build path includes all the WordNik jar files

What am I missing?

Think you're missing the .*

eg import com.wordnik.client.model.*;

With newer implementations of ADT, you shouldn't be using Add External Jars. Just put the JAR file in the libs folder of your project.

In case someone else is going down this same rabbit hole...

There were a couple of reasons for my issue:

1) Although Maven said the build was successful, it was not. It turn out getting the source via the .zip files as some suggested does not always work. You should use the Git command:

Either git clone https://github.com/wordnik/swagger-codegen.git or git clone git@github.com:wordnik/swagger-codegen.git cd swagger-codegen\\samples\\client\\wordnik-api\\java mvn package

2) Installing ALL the libraries causes conflicts. The libraries to install are:

wordnik-java-client-1.0.0.jar jackson-annotations-2.1.4.jar jackson-core-2.1.4.jar jackson-databind-2.1.4.jar jersey-client-1.7.jar jersey-core-1.7.jar

It would be nice is the wordnik documentation was just a little bit more explicit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM