IntelliJ IDEA does not detect classpath library jar file

已回答

I am attempting to add an external jar to my module's build path. I've added the jar as a module dependency and as a library, and the compiler is still unable to find the jar. I'm using intelliJ 14.1. I have verified that the jar is intact and not corrupt.

BwxRE.jpg

HKFAK.jpg

0
Avatar
Permanently deleted user

I am having the same issue. Very frustrating


0

Please attach a sample project with a jar that will reproduce the problem.

0
Avatar
Permanently deleted user

here ya go.  If you look in the main activity in the sample Android project, you'll notice that the import from the other module does not work.  Thanks in advance for your help.



Attachment(s):
Archive.zip
0

You need to enable Export checkbox so that this library is available to the myapp via the module dependency:

http://i.imgur.com/u6ti4ge.png

0
Avatar
Permanently deleted user

I am having the same problem. This does not seem to work. With Eclipse, this works out-of-the-box, but with Intellj, I have gotten very frustrated. 

1

Do you work with Android Gradle project? What is IDE version? Can you provide a project with the example of the setup?

0
Avatar
Permanently deleted user

I am having the same issue.
With each upgrade, more and more basic problems appear. Eclipse become more atracttive and it is free. Very frustrating

1

@victor could you elaborate on your exact problem? There could be many different set-ups and similar issues. Thanks.

0

I have the same issue. I tried adding a jar to the library classpath as well as the module dependencies. I am using the "war" plugin for "providedCompile" but also tried without it using "compileOnly" and I get the same issue.

providedCompile group: 'com.blah.extra_jars', name: 'com.blah.json4j', transitive: false, version: '1.0.69'

> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find com.blah.extra_jars:com.blah.json4j:1.0.69.
     Searched in the following locations:

Project


Mac OS - Ventura 13.3.1 - M1 Chip
Java version: 1.8.0.311 (powered by Jenv)
Gradle Wrapper - gradle-7.2-bin.zip

Intellij

Build #IU-231.8109.175, built on March 28, 2023

Runtime version: 17.0.6+10-b829.5 aarch64

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

 

Project is proprietary so trying to share what I can.

0
Does it help if you try one of the below?

* Adding the dependency via build.gradle file

or

* Adding the dependency from the Project Structure dialogue and switching to build and run the project by using IntelliJ IDEA(Preferences/Settings | Build, Execution, Deployment | Build Tools | Gradle)
0

Ethan,

It was not clear what you meant by "adding the dependency via build.gradle file"

I added it here:

buildscript {
repositories {
mavenLocal()
maven { url "https://jcenter.bintray.com" }
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.24.4'
classpath 'com.blah.extra_jars:com.blah.json4j:1.0.69'.  <---- new line here but same error, file also added in modules and library path in Intellij
}
}

IDEA(Preferences/Settings | Build, Execution, Deployment | Build Tools | Gradle) shows its using Gradle and not Intellij.
I use the build gradle build icon that hovers over the file and I tried the gradle side menu as well
 
Does the jar file need to be in any specific location for the import to work? I know in Eclipse it needs to be in the project itself and not outside of it. Also in Eclipse attaching the jar to the class path does work in other projects with a similar setup. In fact this project has no submodules or anything complicated. Its basically a hello world gradle app at this stage.
 
Note I was able to get this working by doing this but it is not an ideal solution for reasons your well aware of.
I hope we can find a solution using the normal features in Intellij just like Eclipse. I could have put this jar anywhere I believe as long as gradle has permissions to process it.
providedCompile files("lib/com.blah.json4j_1.0.69.jar")
0

请先登录再写评论。