Can't add libraries to my project

Answered

I've been trying to add a java library folder to my project but after selecting the folder and clicking ok nothing happens, as if I clicked cancel instead of ok. But if I add the same folder to global libraries it works without any issue. I'm using IntelliJ 2020.3.1, earlier I was using 2019.3 and it was working perfectly fine in that.

22 comments
Comment actions Permalink

Hello,

Does it help if you temporarily disable all downloaded plugins under File | Settings | Plugins > Installed and restart the IDE using the File | Invalidate Caches & Restart menu option?

0
Comment actions Permalink

There was an update for IntelliJ, don't know if it fixed this issue or something else did. As even after the update I was not able to add libraries to the project, but when I added a library to a particular module and restarted IntelliJ, that library seemed to come in project libraries too which was not happening earlier. So I deleted the library from module libraries and added dependency to all modules from project libraries.

0
Comment actions Permalink

Thank you. Let us know if you come across this problem again.

0
Comment actions Permalink

Arina Efremova I'm having this same problem all of a sudden and I did what you suggested, disabling all downloaded plugins and restarting with the invalidate caches option and after restarting, still no love. I go to add a library from the Project Structure window (CMD+;), from Libraries, click the Plus, select Java, hit my folder, grab the .jar file ... click Open ... and it goes back to the Project Structure window and stares at me like I owe it money or something.  :-|  It certainly cares nothing about bringing my library in ... that's for sure.

0
Comment actions Permalink

Mike Sims What's the version of your IDE?

Can you add it to the Global Libraries? Did you try picking other .jars?

Do you have anything configured in the File | New Project Settings | Structure for New Projects dialog?

Please attach the idea.log file (Help | Show Log in Finder) after reproducing the problem. You can upload it to https://uploads.jetbrains.com/ and provide the upload id.

0
Comment actions Permalink

Mike Sims Did you try adding the library in a particular module? Cause that workaround worked for me. Once you add it to a particular module then you can see the library in Project libraries and you can add it to any module you like.

Arina Efremova Although this is still a workaround, the normal way still doesn't work for me either. I'm on the latest IntelliJ version.

0
Comment actions Permalink

Arina Efremova Sorry for the delay.

I'm using 2020.3.3. (203.7717.56) 

And I gave up trying to solve the problem, I just uninstalled, wiped out my Idea sub folders in my Library folder then re-installed and its working great now. Although I lost all of my projects history which I'm pretty bummed about. But those folders will still be in my Time Machine backup if there's a way to recover the history of my projects that would be pretty cool.

 

And that's a good question, I didn't try adding to the global libraries ... in fact I actually forgot that existed cause I never use it ... not sure why. I use to use it a lot a couple years ago.

I did gain some key mappings that I had lost for some reason a long time ago ... like CMD+SHIFT+8 for vertical editing mode which I use a lot... for some reason that key combo was indeed mapped to that function but it just didn't work but now everything is working normally. I even backed up my settings and re-imported them after the re-install so I got pretty much everything the way it needs to be ... except for the history of my project files ... which like I said ... im really bummed about that.  Where are those things stored anyway?

By the way when I lost the ability to add libraries ... I was playing with a library and compiling it from one project then I would go add it to another one. And it was working fine until it just stopped working. Like I specifically remember adding the library and it worked, then I went to add another one and it didn't work. No changes anywhere else ... just straight up quit working. Like something got corrupted somehow in the library folders somewhere.  I do tend to be pretty fast with this stuff cause I get impatient waiting on software to catch up to me so I tend to do things like click in places where I anticipate its going to follow me ... if that makes any sense ... and maybe I just confused it... lol

 

Thank you,

Mike

0
Comment actions Permalink

Sndysngh I'm not quite sure what you mean by adding the library to a specific module...

If your setup still isn't working, I highly recommend backing up your settings to a file, then nuking everything and re-install. It's like a colonic for IntelliJ ... it seems pretty happy now.  lol

0
Comment actions Permalink

Mike Sims 

Thanks for the info.

I specifically remember adding the library and it worked, then I went to add another one and it didn't work

Could it be that the path to that other library contained an exclamation mark? (IDEA-160951)

If you ever face the problem again, try scanning the idea.log file for any errors. There may be hints there at what went wrong.

if there's a way to recover the history of my projects that would be pretty cool

The list of recently opened projects is stored in the <IDE config dir>/⁨options⁩/recentProjects.xml file. If you wiped out the directory's contents, there is no data left to recover it from.

Sndysngh

Please disable all downloaded plugins, restart the IDE, reproduce the problem and share your idea.log file (Help | Show Log in...). You can upload it to https://uploads.jetbrains.com/ and provide the upload id.

0
Comment actions Permalink

Arina Efremova No, no exclamation marks anywhere in the path of the library I was adding. Thanks for the info on Idea.log, I'll look at that if it ever happens again. I did upgrade to 2021.1 today and kind of a related issue ... when I open projects, my manually installed libraries are not recognized for some reason (same behavior as what happens when I start a new project from a template that I made, I always have to remove my manually added libraries and re-add them) but what is different about this, is that when I remove the library, then add it, I get the usual popup message asking me if I want to do this, then I click yes, then I click OK and the library isn't added. But then. I go back to add it a second time, and I get one message asking if I want to do this, and I say yes, THEN I get a second message only the second one is more colorful and it's shaped differently and it asks me again if Im sure I want to do this and when I click yes, that time it "sticks"... that second message seems more like the type of message that is unique to the new security features in Idea ... but it's just odd that I have to do it twice.

Besides that, I love the new update. lots of really great features. You guys work hard and deliver a great product. Kudos!

0
Comment actions Permalink

Arina Efremova - OH I forgot to mention, I do have a backup of that old libraries folder that I deleted.  Would I be able to recover the edit history of my projects with that backup? Im talking about the history that you get when you - for example - right click on a class in the left pane file browser and go down to History then show history for a class and it shows you all the past versions of the class as you make changes ... that's the history Id like to recover if possible.

0
Comment actions Permalink

Hi Mike,

my manually installed libraries are not recognized for some reason

The reason is this bug: IDEA-266391 (it's cumulative). Long story short, indexes weren't properly rebuilt upon upgrading, hence the issue that you're facing.

The bug is fixed in the latest EAP available here (macOS & Windows) and here (Linux), so you can download and install one of these versions if invalidating caches doesn't help.

Im talking about the history that you get when you - for example - right click on a class in the left pane file browser and go down to History

Local History is stored as a set of binary files under the /LocalHistory subdirectory in the IntelliJ IDEA system directory. So yes, you should be able to replace the folder's contents with stuff from your backup and the history updated in IDEA.

You can also watch this video for a live demonstration of all Local History features.

0
Comment actions Permalink

Hi there, for me it was because of Julia plugin and  I think intellij should fix the plugin.  because after installing it, we can't add libraries an also we can't manage modules in project structure page. I fixed them both by disabling Julia plugin.

0
Comment actions Permalink

>for me it was because of Julia plugin

As I see this plugin is maintained. Could you please report the issue to the plugin vendor: https://github.com/JuliaEditorSupport/julia-intellij/issues with IDE logs attached. Thank you.

0
Comment actions Permalink

Another twist to this tale.  I could not get 2021.2.3 or 2021.3 to add a new 2.15.0 log4j slf4j library (for the new vulnerability).  After going around several times with the various solutions here I hand-edited the .idea XML files to add the needed library.

After clearing caches, restarting and rebuilding it appears in both the Libraries and Artifacts for the project.

The Jar artifact runs FINE ... but it throws a java.lang.NoClassDefFoundError when trying to debug or run it inside the IDE ??!! Weird.

Guess I confused IntelliJ somehow and not sure how to proceed.

 

0
Comment actions Permalink

Todd Hill Clearing caches could help.
If you have steps to reproduce and a sample project, we'd like to investigate that deeper. Feel free to create a new YouTrack ticket for that: https://youtrack.jetbrains.com/newIssue?project=IDEA

0
Comment actions Permalink

My apologies. While writing a ticket on YT discovered I had the wrong combination of Jars that was causing the issue.

Now it runs fine both in the IDE and from the artifact Jar.

Please delete this comment if this is wrong or inappropriate from JetBrains perspective.  A potential solution:

  1. Close the IDE.
  2. Edit .idea/artifacts/(artifact-name).xml and simply add the needed Jars.
  3. Edit .idea/libraries/(project).xml and do the same. Note the CLASSES paths have a trailing ! exclamation.
  4. Start IDE, clear caches and restart.
0
Comment actions Permalink

As it all-too-frequently does, IntelliJ again lost its mind and doesn't recognize my manually added libraries.  The usual routine is to delete the library and re-add it, occasionally having to restart and/or Invalidate Caches and restart.

However, this time, I press + (add) and it comes up with the Java / Maven / Kotlin JS choice dialog, but when I select Java, nothing happens.  Same for Kotlin.  It *does* bring up a dialog for Maven.   I've tried adding to Global Libraries, but pressing + there doesn't do anything.  I've disabled downloaded plugins, Invalidated Caches... 

I am now Dead in the Water and cannot do any work.

I uploaded my log with upload ID: Upload id: 2022_05_04_EsFmn1UR4fa8YrmX (file: idea.log)

Running 

IntelliJ IDEA 2021.2 (Ultimate Edition)
Build #IU-212.4746.92, built on July 27, 2021
Licensed to Linus Kamb
Subscription is active until September 12, 2022.
For educational use only.
Runtime version: 11.0.11+9-b1504.13 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8

Kotlin: 212-1.5.10-release-IJ4746.92

0
Comment actions Permalink

Linusk: It is possible to add libraries by hand.

  1. Stop the IDE.
  2. Edit .idea/libraries/[project].xml
  3. Carefully add the new library, and notice the trailing bang !
  4. Restart the IDE.
  5. Update the project artifacts accordingly.

Hope this helps.

 

0
Comment actions Permalink

Update fixed it.  Thanks for the pointers.   Just weird to me that it just stopped.

Thanks.

0
Comment actions Permalink

Glad it's working for you.

Oddly mine still does not let me edit the library list inside IntelliJ.  I have to edit the file by hand.

Running the latest version.

 

0

Please sign in to leave a comment.