Cannot find the "GoogleAccountManager" in the google plus example - java

While trying the google plus API example from the project site I'm completely stuck with one import:
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
This thing just doesn't seem to exist in the project.
The sample is a read-made Eclipse project I imported, and to be sure I checked if the massive amount of .jar's in the /lib directory are added to the build path. They are, I can see them listed in the Referenced Libraries part in my Eclipse project.
I can find mentions of com.google.api.client.googleapis.extensions.android2.auth but there just doesn't seem to be any GoogleAccountManager class around.
Several possibilities I have come up with, but can't find out which is it, let alone find a solution to them:
I have not set up my project correctly. I doubt it, but completely possible. This would mean that the example has a broken project set-up and/or I managed to not import all libraries?
The class or package or something like that is renamed // named differently. This would mean the example is broken out of the box, and that I still need to find the correct class (and change the import + calling code to that)
Something else :D
The following are the contents of the libs directory as you can also browse on the project page . Notice that it does containt google-http-client-extensions-android2-1.6.0-beta.jar
google-api-client-1.6.0-beta-sources.jar
google-api-client-1.6.0-beta.jar
google-api-client-extensions-1.6.0-beta-sources.jar
google-api-client-extensions-1.6.0-beta.jar
google-api-client-extensions-android2-1.6.0-beta-sources.jar
google-api-client-extensions-android2-1.6.0-beta.jar
google-api-services-plus-v1-1.3.0-beta-sources.jar
google-api-services-plus-v1-1.3.0-beta.jar
google-http-client-1.6.0-beta-sources.jar
google-http-client-1.6.0-beta.jar
google-http-client-extensions-1.6.0-beta-sources.jar
google-http-client-extensions-1.6.0-beta.jar
google-http-client-extensions-android2-1.6.0-beta-sources.jar
google-http-client-extensions-android2-1.6.0-beta.jar
google-http-client-extensions-android3-1.6.0-beta-sources.jar
google-http-client-extensions-android3-1.6.0-beta.jar
google-oauth-client-1.6.0-beta-sources.jar
google-oauth-client-1.6.0-beta.jar
gson-1.7.1.jar
guava-r09.jar

On the first page is a link to updated Google plus libraries google-plus-java-starter_v5.zip
Updated Link: google-plus-java-starter_v5.zip
It contains android/libs/google-api-client-extensions-android2-1.6.0-beta.jar, which contains GoogleAccountManager class.
As this is an extension it probably needs other jars too.
(summary of comments)
Manually adding /libs/google-api-client-extensions-android2-1.6.0-beta.jar to the build path and verifying that it is in the Referenced Libraries fixes the problem. It is unknown (to me (Nanne)) why this doesn't happen automagically when adding the libraries, but there you are.

Right-click on Project, select Properties->Java Build Path->Order and Export Tab->click on checkbox for “Android Private Libraries”. That worked for me.

Related

Can't import MediaPlayer from External Libraries

Ok I read too many Threads from many people who somewhat have a similar problem but none of them solved my problem so please assist me with my huge "pain in the ass"-problem which I seem to not fully understand.
I'm trying to use the MediaPlayer Class from javafx.scene.media and sadly the media class isn't inherited in the default SDK's since Java 9 I think and I'm using Java Version 12. So naturally I have to add the jafafx.scene.media library (jar-Format) manually which should be the easiest step in the world.
I am able to add it via "Project Structure -> Libraries -> Add Library" and it shows up in my external library menu but none of my classes can import it.
That's my first Java project (I come from C#) and I even asked my proffessor but he didn't have a clue either. I even tried to create a new project and add it but with no success.
(I tried adding the library via Maven-Dependency, too, with no success)
Then I thought that another library could work and I added vlcj (VLC-Player) and at least it does find something to import after going to "Project Structure -> Modules -> Dependencies" and changing the vlcj library from compile to Provided.
But now when importing I get the following error:
Error
I am so confused. And it's even for a school project.
Please give me advice if you have any or tell me if I need to drop more infos.
Much Love
Kong
Adding a library is not enough, the library must be also in the module dependencies.
Also, if you are using Java 9+ module system, you have to adjust your module-info.java file for that. Or just delete this file and don't use Java modules for this project for the sake of simplicity.

How can I get stdlib.jar working in Intellij?

After some hours of researching i still have a problem with my stdlib. I've imported lib just like it says on this link (https://intellij-support.jetbrains.com/hc/en-us/community/posts/206850425-How-to-use-a-external-jar-in-a-Java-application) but it still not working. When I type StdDraw.setScale(-100, 100); set scale goes red and intellij says "can't resolve symbol". I'm adding some screenshots so you can see what's the problem. And ignore name of Java classes i'm SLovenian haha ;-)enter image description here
Thanks for your time!
If you tried with project structure > add libraries > stdlib.jar and not working consider this:
I had the same problem and after a deep search I found the reason. You have to use a different stdlib.jar file. Download this stdlib-package and add import edu.princeton.cs.introcs.StdDraw;on the top of your .java file. (you can change StdDraw, Draw, StdIn, etc on top, your compiler will probably help you to import the right libraries)
OK I get it. Just import StdDraw class in src of your project and don't use a package. Then it starts to work fine.

Updating JAR Library in NetBeans

I have a JavaFX project that I have been programming in NetBeans. I'm using a version of a JAR file in my libraries and a newer version has come out. I tried to remove the first version and then add the new version in by right clicking the Libraries and then clicking "add JAR/Folder." It adds just fine but then all my imports will not resolve to the new version. I get errors saying that the import can not be found and none of my methods that use that library can find their objects either. If I right click on the little yellow lightbulb on the left, normally I would get an "Add import for ________" But that doesn't even show up. Only "Create class ______ in _______." I know the actual objects haven't changed names and the imports are pointing to the right locations, none of those have changed either. If I add the old library back in it works fine.
Is there a way to update the library. Something like "Refactor to new JAR?"
After looking into it some more and doing some extensive trouble shooting. I figured out that the update was a bad file. By using a slightly earlier version of the jar file but still newer then the one I was using I got it to work. Guess I just need to wait for the developer of the "Update" to fix their file. Thanks guys

Implementing ActionBar-PulltoRefresh by Chris Banes, library errors etc

Following up on my previous question about importing a certain library from github in my project, I decided I wanted to implement a different one, but I get lots of errors at this point.
Importing Android Listview refresh by pull, project-properties error
In line with Google currently using Chris Banes' ActionBar-PullToRefresh: https://github.com/chrisbanes/ActionBar-PullToRefresh,
I've decided I wanted to used that library as well for the Android app that I'm currently developing for my internship. When I try to import the existing code into the workspace from the unpacked zip-file though, I instantly get a ton of errors, in the library as well as in the example activities. For instance, in the library folder, in ActionBarPullToRefresh.java, it underlines Class within the first private hashmap and says references to the generic type Class should be parameterized.
The IDE (eclipse) also gives tons of errors to the other folders included, and when I add the library folder to the libraries of my main project, using the properties -> android tab, it carries over the errors to that project (quite logically).
Could anyone send me into a direction as to how I should successfully import and use this library?
I will write this here for future PullToRefresh users. I use IntelliJ IDEA instead of eclipse, so remember that the word Module and Project are equivalent. When you have to add a project to Eclipse, the action is add module in IDEA.
Example with ActionBarSherlock (ABS from now).
What you have:
You have a Module named: MyProject. This is your main Android module.
You want to add PullToRefresh to a few Fragments (for example) in your MyProject.
Step One: Download and Copy.
I personally like to have a clone or fork of the libraries I'm using to read the commits and change logs. Not only you learn by seeing other people's code, but also you get the "latest news" about the libraries you use. It's a win-win situation. Remember what Jeff Atwood said: "Read The Source, Luke". So in order to do this, Clone ActionBar-PullToRefresh from the right URL.
Now I don't like having the clone with my modules/projects so I usually clone projects somewhere else and later manually move what I need. It's tedious but that way I only get what I want. So what do you need then? The clone contains two important directories: Extras and Library. We're going to need stuff from these.
Copy the library directory to your project root: /path/to/your/project/pulltorefresh
Copy the corresponding (ABS or Compat) extra to your project root as well…
This is what you got so far:
/path/to/your/project/MyProject
/path/to/your/project/pulltorefresh
/path/to/your/project/pulltorefresh-abs (or compat)
Step Two Import these:
Import these modules (projects in eclipse) into the project/workspace. This should be simple if you know your IDE, but as a quick reference: File -> Import Module -> find the pulltorefresh folder from above (and the -abs or compat later) and follow the wizard. If you're using Eclipse, check this link to know how to do it.
Now you should have in your left panel (⌘1) the following structure
MyProject
pulltorefresh
pulltorefresh-abs
Step 3 Add the right references
Assuming MyProject has actiobnarsherlock.jar (because you need it) or the corresponding android support library for compat and that you have the corresponding android-support-v13 (or v4) as well…
pulltorefresh doesn't need any library reference.
pulltorefresh-abs needs a reference to: pulltorefresh, android-suppport-vX and actiobbarsherlock
MyProject needs a reference to: pulltorefresh-abs, android-suport-vX and actiobbarsherlock
Of course both android-support and actiobarsherlock could sit in MyProject and be exported (and taken from there) by the other libraries, but that's project management 101 ;)
Step 4 Integrate!
This is easier, just follow the Quick Start Guide.
REMEMBER: in older versions of the lib you had to have an attacher in an Activity, that is no longer necessary. Read the documentation, it's very simple (and much more flexible this way).
Wait, What If You Don't Use Either Sherlock or Compat??
I haven't done this yet, but my guess is:
Don't import -abs or -compat in extras. Just import pulltorefresh.
From your project, reference pulltorefresh.
Hold on… what about imports?!
Getting the right imports is important for any library, you have to pay attention and not blindly let your IDE do it for you (or at least always double check what you're importing). You'd be surprised to see how many "name collisions" are out there.
For Action Bar Sherlock based projects, the imports should be:
import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout;
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;
For a non sherlock pure project:
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.listeners.OnRefreshListener;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout;
Where did you get those?!?!?!?!
By looking at the samples, Luke.
For example, here's for the stock version.
The final step would be to profit… but I leave that up to you ;)
If you still have an issue, the guys are friendly provided you don't ask lazy questions. Feel free to follow the project and participate in the issues page at github.
Good Luck refreshing!
I don't use Gradle myself, but we all should, as it is a quantum leap for build technology in the Java (JVM) world (from Gradle introduction). This is how to reference projects libraries for PTR v 0.9.3:
Your project has to reference PullToRefresh aka PTR
PTR has to reference SmoothProgressBar aka SPB, which you can find here, on github
Both PTR and SPB should be Android libraries, so make sure that checkbox is checked (Properties -> Android -> IsLibrary)
The "tricky" part: Once you have cloned SPB on your local machine copy the contents of SmoothProgressBar\library\src\main\java into SmoothProgressBar\library\src\main\src (that is the structure ADT expects)
remember to add the support library to SPB if you target lower that 14
Assuming you know how to reference an android library project in eclipse (if not, google it), that is all about you need to do.
Good luck! :)
Non-senior developers/git users might find the following link useful (like I did) http://www.rahuljiresal.com/2014/04/actionbar-pull-to-refresh-on-android/
rahuljiresal has created a git project that contains both Chris Banes' Actionbar-PullToRefresh AND the referencing SmoothProgressBar all in one: https://github.com/rahuljiresal/ActionBar-PullToRefresh
The steps described above by Martin i.e.
1. Download/ Clone git project locally
2. Import PTR library into Eclipse
3. Reference PTR library from your project
4. Integrate
are still valid, but the whole process is incredibly easier and plug-and-play.

m2eclipse marking 'target' directory as 'Derived'

I have a Maven Java project, imported using m2eclipse.
The target/ directory is not marked as 'Derived' by m2eclipse.
Problems:
It is validated, so any validation error appear twice. My example shows a JSP Problem, when I insert intentionally an error in a jsp.
When I want to open a resource with Ctrl-Shift-R, all files appear twice, and I run the risk of editing the copy instead of the original file.
Possibly see post eclipse-ignore-folder
Note: When I set manually the directory to derived, the validation problem doesn't disappear, so that would only be part of the solution...
Question:
Is there something I need to do, so that m2eclipse sets the target/ directory to 'Derived' ?
Yeah, that has been around for a while. I wrote a plug-in that allows you to mark directories as "derived" without having to find them all (http://eclipsefrills.sourceforge.net/). It's not great, and you still have to manually run the action to make it work, but it may help.
Odd, though, I have not noticed the problem lately, myself. I wonder if there is some setting in the preferences that takes care of this now.
Good luck.
I got rid of this problem by writing a custom plug-in KeepTargetDerivedPlugin. As its name suggests, it automatically keeps all target folders derived (unlike the other solutions, which require user action).
Still, e. g. the YA2O's plug-in can be used to mark derived folders of projects which already reside in the given Eclipse workspace.
Yes: open a bug report :)
I have been so annoyed by this problem that I wrote a plugin to solve it. You can get the source and jar from here.

Categories