Can anyone recommend some good Gradle tutorials? I...
# getting-started
t
Can anyone recommend some good Gradle tutorials? I'm having a hard time finding good Gradle tutorials... I also want to work with the Kotlin DSL
google 2
t
@Brian Dilley thanks I will look at this. 👍
b
Is there anything specific you’re looking for? I generally create a Kotlin based Gradle file from IntelliJ to get started with, and go as I see fit.
t
@bodiam how do I do this? I tried but it didn't work... In Android Studio they automatically have a gradle wrapper so it uses gradle by default, but I'm having trouble with IntelliJ...
b
you go to
File -> New Project -> Gradle -> check Kotlin DSL build script -> pick Kotlin/JVM
, and that should do it.
t
@bodiam Ok I will tell you if there are problems
b
that’s fine, happy to help.
t
@bodiam do I need to also check 'java'?
b
I depends. Only if you’re planning on using Java. You can enable it, it doesn’t hurt, but it’s not needed.
(I think it will only enable the Gradle Java plugin, nothing more)
t
@bodiam I get this:
b
not sure what that is. Could be just a warning.
or maybe click on the
Load Script Configurations
t
@bodiam I did... but it returned, when I press '?' I get this:
b
I just created a new project myself, I’m getting the same warning as you. Gimme a moment
t
@bodiam yeah... strange... with Android Studio gradle was automatically integrated in my project, so at least I don't have to worry about that
b
okay. I got the same message as you, but only while it was indexing (downloading Gradle, indexing libraries, etc)
after that, the message went away
Screen Shot 2021-03-22 at 2.03.55 pm.png
this is before
image.png
and this is after indexing / downloading gradle was completed
t
@bodiam maybe I didn't install gradle properly?
b
you don’t have to, IntelliJ will download the gradle wrapper itself
t
@bodiam I got this
b
you could try reloading the gradle project
image.png
well, that might be an issue indeed.
I don’t have a
JAVA_HOME
set
t
@bodiam should I just delete the 'java_home'
b
if you don’t need it, then yes
t
I got this also:
@bodiam how come with android studio gradle works fine though but not with IntelliJ?
b
not sure, I don’t have experience with Android Studio
t
@bodiam have you set any environment variables for Gradle?
b
maybe just remove that whole Gradle directory? (or maybe it’s in use by something, like Android Studio?)
not sure what you mean with
environment variables for Gradle
. Why would you want to do that?
t
@bodiam I don't know... I"m just confused why I'm getting these annoying problems.
b
Oh, I call it “Software Development”
🤣 1
it’s an endless series of annoying problems 🙂
t
@bodiam how did you install gradle in the first place?
b
I didn’t
t
@bodiam how did it come up for you?
b
I only use Gradle wrappers
which are auto downloaded by IntelliJ
t
@bodiam How do I use a Gradle wrapper?
b
whenever you create a new Gradle project, there’s a
gradlew.bat
. If you type
gradlew clean build
instead of
gradle clean build
, (not the
w
), then it will use the wrapper. The wrapper will download Gradle if it’s not in the project yet, so you can have 1 project use Gradle 3.4, and the other 4.6, for example, instead of needing a system wide installation (which is common with Maven for example)
t
@bodiam tried that but i got: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-6.8-bin.zip'.
😞
b
are you behind a (corporate?) firewall / proxy? The link is fine
t
@bodiam?? what do you mean
b
I’m not sure how to rephrase my question.
t
I'm not sure what you meant by that question
b
basically, are you connected directly to the internet, or are you at work and this link is blocked by something
(usually a firewall, a proxy server, whatever)
t
@bodiam im not at work... im not behind a firewall also
b
in that case, I don’t know really.
in a case like that, I’d just try again. Sometimes works 🙂
b
What happens if you click that URL Tom
t
@bodiam this is my AS project, it has Gradle by default - but not on Intellij:
@Brian Dilley you're scaring me lol
b
No, I'm trying to help you
t
@Brian Dilley It downloads gradle 6.8 (not wrapper) for me
image.png
It's already downloaded though on my machine
b
might be the same problem as you mentioned before (with the “could not create parent project”)
t
@bodiam maybe I should just uninstall gradle and use the wrapper? I understand you don't have gradle installed you are just using the wrapper - maybe I can try that? sorry if it sounds stupid
b
maybe just kill that directory? maybe something is using it or so, like the gradle daemon, android studio, or what not.
t
@bodiam how do I do that?
b
no, that doesn’t sound stupid, and even if it did, it might work.
just delete the directory.
or like you said, uninstall gradle
t
@bodiam ok.
@bodiam where is the directory located?
b
it’s in your screenshot
t
@bodiam ok
b
c:\program files\gradle-something-something
t
@bodiam OK I uninstalled it, what do I input here:
what does say for your configuration?
@bodiam good news, I think it's working
👏
b
“think” it’s working, or “it’s working?“. How did you resolve?
t
@bodiam i uninstalled the gradle, and it did a clean install of what was needed. Also, How do I create a new Kotlin file in my gradle project?
Also this is how it looks for me (is this how it's supposed to look?):
Nevermind, just created a new file called 'src' and marked it as 'sources root' and it worked.
b
IntelliJ will create (and mark) those directories for you if you give it a bit of time
t
I'm getting this new problem:
It's also not finding 'main' which is strange
b
it’s because you don’t have Kotlin configured
t
@bodiam how do I configure it?
image.png