I'm trying to get Google Cloud Vision API working with Java in IntelliJ. I've followed all the steps at https://cloud.google.com/vision/docs/quickstart-client-libraries. I'm running the following code, just trying to import the packages I need and when I scroll over google, it is underlined in red and says 'cannot resolve symbol google'. How do I fix this?
code and error
The error shown in your screenshot usually happens when an external dependency could not be loaded.
Please make sure you accurately followed the steps in the Install the Client Library section of the guide you followed, in the Java tab of the widget.
From the screenshot I can not really tell what build settings you configured for the IntelliJ project. If you chose no build tools or the regular Ant setup, it might be easier for you to re-setup a project based on either Maven or Gradle.
With Gradle and Maven it is pretty straightforward to add the dependency to the project as described in the guide, otherwise you will have to download all the dependency libraries yourself and add them to your project folder and build environment manually as files.
If you did already use Gradle or Maven for your project, and did follow the guide but it still shows the error, then it's usually a case of IntelliJ not loading those changes yet.
In that case you can fix it by selecting your Gradle or Maven tab in Intellij, and clicking the re-import button (looks like a refresh icon from browsers) to reload the configuration, usually triggering a download of missing dependencies.
Otherwise you can also trigger a full build with running the gradle build or mvn compile targets, which also should download all configured missing dependencies.
Related
I'm having some trouble importing my project from build.gradle file.
It's not able to find classes from hamcrest-core-1.3.jar.
gradle clean build
runs successfully on terminal.
My environment is
Intellij 2016.3.1
Gradle 2.14.1
It was able to resolve the reference one time but it went away on restart. When it was able to resolve hamcrest, it later failed to resolve pigunit jar. I got NoSuchMethodError (class was loaded from wrong jar) also once.
Invalidate Cache also didn't work.
I tried importing the project from scratch multiple times.
Please let me know if any other information is needed.
For some reason org.hamcrest.CoreMatchers loads CoreMatchers from
mockito-all-1.10.19.jar instead of hamcrest-core-1.3.jar.I played around with the order of these two jars in the modules libraries.
Please refer to the screenshot below.
I follow this steps for setting External dependencies:
https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle
(section: External Dependencies Examples >> universal-tween-engine using maven)
After do that, i check maven repo direcory and the files are there:
C:\Users\Admin.m2\repository\aurelienribon\tweenengine\6.3.3
Executing gradlew bat for rebuilding the project returns no errors:
I'm missing something because in Eclipse didn't see the references to Tween engine:
And obviously, if i try to add a reference to Tween Engine on my code i get an error:
How can i set up a new reference on existing gradle project, using libGDX for using Tween Engine in this case?
You did everything correct, but just adding the dependencies will not refresh the dependencies in eclipse.
You have to mark all related projects in eclipse, right click them and perform a Gradle -> Refresh Dependencies. Depending on what exactly you have changed, you might even need to do a Gradle -> Refresh All.
This will update the dependencies in eclipse and you will find the needed classes.
I want to build the LanguageTool Java project from source. This page gives basic instructions for obtaining the "Maven artifact" with all the sources:
http://languagetool.org/java-api/
I'm an expert Java developer but I've never used Maven before. Can someone please tell me how to get the LanguageTool project and all source code into Eclipse so I can modify and build it?
Thanks in advance...
At the bottom of the page you linked (Language Tool) is another link to the svn repository. That's where you'll get the source code and instructions on how to build the tool yourself.
In general, open source projects will highlight the maven artifact as it allows others to use their code in the easiest way possible. Only a few folks like to build the code themselves so the links to the source repositories are often less conspicuous.
There is no automated way to do this.
Best is to start a basic maven project (manually or through a Maven Archetype, import the sources in the Standard Directory Layout, and start adding dependencies to the pom.xml in order to get it to compile.
Libraries like commons,lucene,... are pretty easy to find in the various maven repositories).
Other libs you will probably have to install yourself in your local repository or remote repository.
There's a maven plugin for eclipse if that is your preferred IDE.
This isn't intended to be a question. Rather, an observation which is a common problem found in Android when you use external APIs for development and android.jar isn't duplicated into your project!
After searching through various forums, Google and stackoverflow, I seem to get a solution by myself and thought of sharing it.
Whenever you are linking external libraries, better link it by creating a /lib folder and dump those .jars there(means to COPY the files and NOT linking them). Link them using Eclipse -> Build Properties -> Configure Build path -> Library tab -> Add external Jars. Add the required .jars saved in /lib folder in this. (Note that, the jar included as a "Referenced Library" in Eclipse will disappear in /lib folder! But, not to worry as proper linking has happened. Another note is to check that the /lib jar that was referenced should NOT be visible in Libraries tab of Build Properties as it will be inherited.)
Another major problem was when Google APIs are being used. Specially the ones, which use some core library functions of java/javax. Be very careful of this. The error is that, the DalvikVM tries to link these but fails as there is a duplication found and is unable to decide which one to refer to. Below is the error.
Dx trouble processing "javax/xml/namespace/QName.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
In such cases, what I have observed is that, this class is used in xpp3-1.1.4c.jar. If you've copied this into your /lib folder, PLEASE REMOVE IT. Then clean the project, and give a fresh build. And the ship sails smoothly thereafter.
Do this for other referenced .jars if such duplication exists.
Cheers!
This worked for me. I'm using maven, and the xpp3-1.1.4c dependency shows up under "Maven Dependencies"; I had to exclude it using (right click the dependency) Maven-> "Exclude Maven Artifact...". Thanks a bunch -- this was really obscure.
This error show only when you trying to generate signed APK.
There are 2 ways to fix this.
1. As commented Amira Elsayed Ismail in this post this
we should revert to gradle 2.3.3.
To do this you should also download Android Studio 2.3.3 because studio 3.0.1 require gradle plugin 3.0+
This was the first solution. But reverting Android Studio and gradle plugins is a painful solution.
2. Resolve all dependency conflicts.
When i revert gradle, Studio 2.3.3 showed we interested warnings(i do not know why studio 3.0.1 don't show dependency conflict warnings)
Warning:WARNING: Dependency xpp3:xpp3:1.1.4c is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
So these dependencies are ignored for debug but NOT FOR RELEASE.
I fixed this by excluding these dependencies.
configurations {
all*.exclude group: 'xpp3', module: ['xpp3' ,'httpclient']
}
After this, i successfully generated signed APK using gradle 3.0.1.(without reverting).
I'm having some issues making the maven google app engine plugin work properly.
First of all, I'm not even sure if the archetype I'm using is the correct one, their examples show version 0.7.0 but it seems like never versions exist (i tried 0.9.1 and that works), where can I find a overview of what versions of the plugin is available?
Secondly, the archetype seems.. messy, I don't like the package structure and it doesn't seem to actually include the GAE and GWT dependencies. I have to manually add them to my project in Eclipse, which kind of defeats the purpose of using maven. And how come they are breaking the gwt maven plugin? I know that one includes the actual gwt jars as maven dependencies?
I'm fairly new to Maven, but I have been using the gwt maven plugin for a while, and I'm very happy with everything about it. Is there any way I could just their archetype to do the base project and add the gae plugin to it?
UPDATE
I suspect the problem I'm seeing with the GAE maven plug-in is in regards to undefined properties in the POM. I have no idea if its due to error these aren't set-up or if its due to me actually have to manually set them up. The documentation on this plugin is sparse.
Thanks for the answer below, but I really don't want to add another archetype into play. I think the best solution for me is to try and adapt a GWT maven project manually, to include support for GAE.
I've used the archetype like so :
http://code.google.com/p/gae-mvn-archetype/
to generate a GAE project template.Then manually added my other dependencies. This got me a usable project which I can deploy to GAE and everything.
Also, for Eclipse importing, once the template project was done, I've imported it into eclipse using the m2_eclipse plugin :
http://m2eclipse.sonatype.org/installing-m2eclipse.html
(note that i've imported it into Eclipse as a Maven project, NOT as an Eclipse whatever project)
This imported the thing into eclipse with all the necessary dependencies and without errors.