How to Import Library in build.gradle

I've written the url in "repositories" and "implementation('kryonet:kryonet:2.21')" in "dependecies" section, but gradle can't sync it.
No description
45 Replies
JavaBot
JavaBot4w ago
This post has been reserved for your question.
Hey @aliinuur! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st4w ago
The Screenshot is Maven syntax Are you using Maven or Gradle?
aliinuur
aliinuurOP4w ago
gradle
dan1st
dan1st4w ago
What is the actual configuration you are using? What happens when building from the command-line?
aliinuur
aliinuurOP4w ago
No description
aliinuur
aliinuurOP4w ago
i tried a fresher fork of this library but Intellij can't see it still
dan1st
dan1st4w ago
I don't see the clojars URL in the repositories section
aliinuur
aliinuurOP4w ago
this fork is on jitpack.io
dan1st
dan1st4w ago
first build it with the command line and then check whether it works with IntelliJ (once the CLI works)
aliinuur
aliinuurOP4w ago
you mean gradle task build?
dan1st
dan1st4w ago
yes in your terminal and please include the full output as text (not as a screenshot) if it fails
aliinuur
aliinuurOP4w ago
it didnt fail
dan1st
dan1st4w ago
What exact command did you run?
aliinuur
aliinuurOP4w ago
Gradle sync went with no errors
dan1st
dan1st4w ago
ok
aliinuur
aliinuurOP4w ago
but when i try to import com....kryonet it doesnt see the lib
dan1st
dan1st4w ago
that one is IntelliJ-specific Do you have multiple build.gradle files?
aliinuur
aliinuurOP4w ago
yes
dan1st
dan1st4w ago
Did you put it in the common one?
aliinuur
aliinuurOP4w ago
one for android and desktop yes
dan1st
dan1st4w ago
I think LibGdX has a common module Can you show it?
aliinuur
aliinuurOP4w ago
i put it in the projects builld.gradle
dan1st
dan1st4w ago
no, there should be a third one 4th*
aliinuur
aliinuurOP4w ago
No description
dan1st
dan1st4w ago
core that's the one where you need to add the dependency I think
aliinuur
aliinuurOP4w ago
this is core/build.gradle
No description
dan1st
dan1st4w ago
ehhh ok
aliinuur
aliinuurOP4w ago
all dependencies loaded through Projects build.gradle
dan1st
dan1st4w ago
Does that one have a project(":core")?
aliinuur
aliinuurOP4w ago
yes it does have
dan1st
dan1st4w ago
Can you show it?
aliinuur
aliinuurOP4w ago
i didnt touch it
dan1st
dan1st4w ago
Does it have a dependencies block? Can I still see it?
aliinuur
aliinuurOP4w ago
No description
dan1st
dan1st4w ago
try adding the dependency there
aliinuur
aliinuurOP4w ago
i see now thanks
dan1st
dan1st4w ago
core=common between desktop and android so any dependency that should be available in the common code must be in the core module/project
aliinuur
aliinuurOP4w ago
thank you! it works!!!
dan1st
dan1st4w ago
Note: If you put an implementation dependency there, you won't be able to use it from desktop specific code
aliinuur
aliinuurOP4w ago
i have watched 10 videos about to how import using gradle everyone telling the same "just one line of code" you saved my day
dan1st
dan1st4w ago
well you gotta put it in the right location
aliinuur
aliinuurOP4w ago
ive changed it to api
dan1st
dan1st4w ago
If a project declares an api dependency, it means "this project can use the dependency but the dependency is also propagated to other projects using it" so e.g. api dependency in core means it can be used by desktop and android directly as well while implementation dependencies in core can be used only in common code (and modules explicitly declaring the dependency can use it as well)
aliinuur
aliinuurOP4w ago
:letsgoe:
JavaBot
JavaBot4w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?