The import com.google.api.client cannot be resolved in Eclipse - java

I am getting this error:
The import com.google.api.client cannot be resolved
My configuration is below:
Project Properties - Android:
Java Build Path:
I still get the error below even after restarting Eclipse.
Can anyone help? Thx :D

You haven't added the client libraries in your project.
http://code.google.com/p/google-api-java-client/wiki/Setup.
You will get the google-api-java-client-1.14.1-beta.zip file at the above link.
Save those jar files in your libs folder of Android project.

Add this:
<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty -->
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>

If you are trying to add a Google API to an Android app as I was, and if you are using Eclipse, the following is very easy.
Right-click on a project, select "Google > Add Google APIs...", select
the Google API you need from the list of available Google APIs,
click Finish, and it will automatically download the API client library
From https://code.google.com/p/google-api-java-client/wiki/Setup

Related

How add a firebase dependency in java using eclipse

I want to add the firebase dependency on a java project of jhipster, I'm using eclipse, but when I add this dependency:
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.8.1</version>
</dependency>
that give Firebase, I get this error in my app in Java in eclipse:
The error 206 in english is:
the filename or extension is too long
I appreciate much your help

The import org.mybatis.dynamic cannot be resolved

I want to try the example of dynamic update statement on this tutorial link : http://www.mybatis.org/mybatis-dynamic-sql/docs/update.html. I saw that it needs the import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider; , So i've searched for dependency in the maven central and added below dependency on my pom.xml
<!-- https://mvnrepository.com/artifact/org.mybatis.dynamic-sql/mybatis-dynamic-sql -->
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.0.0</version>
</dependency>
Already tried mvn clean install -U on maven build but still The import org.mybatis.dynamic cannot be resolved error always shows. Where can i have the correct maven dependency for this. Or you can suggest me other dynamic update statement approach on mybatis using xml mapper.
I also added the newest version of it and everything worked as expected. I had the problem, that mybatis-spring-boot-starter did not include mybatis-dynamic-sql.
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.3.1</version>
</dependency>

Firebase in Google app engine throwing noMethodFound error while initialization

I am trying to initialize firebase in Google appengine web app and using maven for dependencies.
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-server-sdk</artifactId>
<version>[3.0.0,)</version>
</dependency>
Getting error
java.lang.NoSuchMethodError: com.google.api.client.googleapis.auth.oauth2.GoogleCredential.fromStream(....)
at com.google.firebase.FirebaseOptions$Builder.setServiceAccount(FirebaseOptions.java:77)
How to solve this issue:
Go to http://search.maven.org/#search%7Cga%7C1%7Cgoogle-api-client and find the last version of com.google.api-client API.
Add the dependency on you project
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-assembly</artifactId>
<version>last version </version>
</dependency>
I do this on EJB project using netbeans and glassfish server, so I download the jar file of the last version com.google.api-client add it on Netbeans Libraries and glassfish libraries, then I compile the project and restart glassfish.

Getting java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DEREncodable during PDF Encryption [duplicate]

I'm trying to use iText Java.
When you run the example "how to sign" the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.tsp.TimeStampTokenInfo
According "Getting Started with iText - How to sign a PDF using iText", I have to use the BouncyCastle.
I downloaded the file: bcprov-jdk15on-147.jar from BouncyCastle download page.
And added to the project: Java Build Path/Libraries/Add External JARs...
I added the following line:
Security.addProvider(new BouncyCastleProvider());
When you run the example the same error occurs.
So I downloaded another file: bcpkix-jdk15on-147.jar entitled "PKIX/CMS/EAC/PKCS/OCSP/TSP/OPENSSL"
And added to the project: Java Build Path/Libraries/Add External JARs...
Now I have two Jars.
When you run the example the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
I tried downloading the file "bcprov-ext-jdk15on-147.jar" but did not solve the problem.
I am using iText 5.2.1 and eclipse on Windows 7 64 bits.
iText marks bouncycastle dependencies as optional. If you require them, you need to add the dependencies in your own pom file.
To find out which dependency to include in your project, open the itextpdf pom.xml file of the version you are using (for example 5.3.2, here) and search for the 2 bouncycastle dependencies.
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
Copy them into your pom file and remove the optional option.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.3.2</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
</dependency>
BouncyCastle libs are undergoing heavy API changes that broke the compatibility with other libs like iText.
Either
use a previous version of BouncyCastle libs. Old versions can be found here. However, you'll have to find the right version of iText that was compatible with this particular version of BC.
make your own build of iText (the SVN trunk has been fixed). iText can be build with Maven (there's a short readme file at the root of the SVN). Please note that it's at your own risk, there may be bugs in trunk.
wait for the next version of iText. From my experience, iText releases come every couple of months, sometime more often, sometimes less. I'm not an iText committer though, so I can't give you any ETA.
More information can be found in this thread
With itextpdf version 5.5.4 org.bouncycastle dependencies are marked as <optional>true</optional>. This means you MUST include those dependencies in your own pom, or you can run into classnotfound exceptions.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.4</version>
</dependency>
<!-- Bouncycastle dependencies necessary as they are optional = true
in itextpdf ... but they're not-so-optional in reality -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.49</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.49</version>
</dependency>
from version of bcprov-jdk15on-147, class of DEREncodable is no longer exist under the path of org.bouncycastle.asn1. You can use version before 146 (including 146) to resolve this question.
It's strange that the jars available at bouncycastle.org don't seem to contain this class. Perhaps, you may want to use one from the locations listed in this page (link).
i have the same problem, but a fix it when i download the libreria and update those files on /WEBINF/LIB
Luckily, the dependency jars are being delivered along with the iText now.
Please check the repository link below and download extrajars.zip file
http://sourceforge.net/projects/itext/files/
For jruby-ers with the same failure, I updated to jruby-complete-9.1.13.0.jar from jruby-complete-1.6.6.jar and the problem seemed to resolve...FWIW...

Android: error including/repacking dependencies which reference javax core classes

I'm working on an Android app using Maven as the build tool. I managed to set evertyhing up correctly (maven dependencies are exported to the apk etc.), however I have one remaining problem which is driving me crazy.
I want to include a dependency on simpleframework's xml parser defined as follows in my POM file:
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.5.3</version>
</dependency>
When I issue mvn install on the project, I get the following error (truncated):
trouble processing "javax/xml/namespace/NameSpaceContext.class" ...
I know the error results from the simple xml parser referencing these javax-classes, however I haven't found a solution yet (setting the --core-library flag is of no use).
I'm currently trying to repack the dependency with the maven-jarjar-pluging but this doesn't seem to work either.
Can anyone help me out with this? Many, many thanks in advance!
Define your simple-xml depedency like this :
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.6.1</version>
<exclusions>
<!-- StAX is not available on Android -->
<exclusion>
<artifactId>stax</artifactId>
<groupId>stax</groupId>
</exclusion>
<exclusion>
<artifactId>stax-api</artifactId>
<groupId>stax</groupId>
</exclusion>
<!-- Provided by Android -->
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>
I use android-maven-plugin, and adding <coreLibrary>true</coreLibrary> to the <configuration> tag of the plugin in the POM works for me. However, there's a bug: https://github.com/jayway/maven-android-plugin/pull/34, that you need to include to fix the plugin you are using, since the bug won't be fixed until 3.0. Here's how I got it working for me using 2.9.0-SNAPSHOT.
add a pluginRepository pointing to http:// oss.sonatype.org/content/repositories/jayway-snapshots/ to get 2.9.0-SNAPSHOT
update your plugin version to use 2.9.0-SNAPSHOT and add <coreLibrary>true</coreLibrary> to pom.xml
get the fix: git clone https://github.com/kevinpotgieter/maven-android-plugin.git
remove src/test/java/com: so the test won't fail
mvn package
copy it and overwrite your local maven cache in .m2 (You may need to remove your plugin repository yours gets overwritten every time.)
Step 3-6 won't be necessary after the fix gets into 2.9.0-SNAPSHOT.
Update July 2010: 2.9.0-beta-4 has the fix, so you don't need the above workaround if you use 2.9.0-beta-4 or later. I tested 2.9.0-beta-5 which worked just fine.
Spring Android uses Maven to integrate Simple. Take a look at the following URL, it should provide pointers on how to get Maven working with Simple.
http://static.springsource.org/spring-android/docs/1.0.x/reference/html/rest-template.html

Categories

Resources