Title
k

kevin.cianfarini

05/08/2019, 3:56 PM
Can someone point me in the right direction?
s

snowe

05/08/2019, 3:57 PM
sure thing.
first things first.
you probably don't need to use the buildscript block in the root
unless that's something for android that I'm unaware of.
k

kevin.cianfarini

05/08/2019, 3:58 PM
okay. I was just trying to convert what android studio had provided with the groovy gradle files
s

snowe

05/08/2019, 3:58 PM
you can probably reduce the root gradle to something like this.
hmm looks like you might need the buildscript.
anyway
allprojects {
    repositories {
        google()
        jcenter()
    }
    ext {
        set("kotlinVersion", "1.3.21")
    }
}

tasks.register("clean", Delete::class ) {
    delete(rootProject.buildDir)
}
after the buildscript to get rid of your error.
also, line 30 of the module, you don't need to specify
project
you can just call
extra["kotlinVersion"]
k

kevin.cianfarini

05/08/2019, 4:01 PM
is it
ext
or
extra
?
I've read conflicting information about that
s

snowe

05/08/2019, 4:01 PM
in kotlin it's
extra
, but the extension method is
ext
.
confusing I know.
k

kevin.cianfarini

05/08/2019, 4:01 PM
okay
s

snowe

05/08/2019, 4:01 PM
so in your allprojects block use
ext
and then when retrieving it use
extra
I've heard it's better.
k

kevin.cianfarini

05/08/2019, 4:04 PM
okay, one thing at a time
still unable to resolve
kotlinVersion
from extra after moving
ext
to
allProjects
s

snowe

05/08/2019, 4:05 PM
hmm.
is this a
build.gradle.kts
or
build.gradle
?
k

kevin.cianfarini

05/08/2019, 4:06 PM
kts
s

snowe

05/08/2019, 4:06 PM
did you change anything that AS generated?
k

kevin.cianfarini

05/08/2019, 4:07 PM
AS generated
settings.gradle
and two
build.gradle
files
I changes all three of those
to
.kts
s

snowe

05/08/2019, 4:08 PM
gotcha. what does your
settings.gradle
look like?
k

kevin.cianfarini

05/08/2019, 4:08 PM
rootProject.buildFileName = "build.gradle.kts"

include(":app")
s

snowe

05/08/2019, 4:10 PM
i think it's actually faililng to find the kotlinVersion in the buildscript.
just hard code it there for now.
k

kevin.cianfarini

05/08/2019, 8:57 PM
hard coded the kotlin version for now. Still dealing with symbol resolution issues in the build. This is the output when I try to run a build now.
Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/home/kevin/.var/app/com.google.AndroidStudio/cache/tmp/
warning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
build.gradle.kts:3:1: error: unresolved reference: buildscript
buildscript {
^
build.gradle.kts:4:5: error: unresolved reference: repositories
    repositories {
    ^
build.gradle.kts:5:9: error: unresolved reference: google
        google()
        ^
build.gradle.kts:6:9: error: unresolved reference: jcenter
        jcenter()
        ^
build.gradle.kts:9:5: error: unresolved reference: dependencies
    dependencies {
    ^
build.gradle.kts:10:9: error: unresolved reference: classpath
        classpath("com.android.tools.build:gradle:3.4.0")
        ^
build.gradle.kts:11:9: error: unresolved reference: classpath
        classpath(kotlin("gradle-plugin", version = "1.3.21"))
        ^
build.gradle.kts:11:19: error: expression 'kotlin' cannot be invoked as a function. The function 'invoke()' is not found
        classpath(kotlin("gradle-plugin", version = "1.3.21"))
                  ^
build.gradle.kts:11:19: error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public val <T : Any> Class<???>.kotlin: KClass<???> defined in kotlin.jvm
        classpath(kotlin("gradle-plugin", version = "1.3.21"))
                  ^
build.gradle.kts:17:1: error: unresolved reference: allprojects
allprojects {
^
build.gradle.kts:18:5: error: unresolved reference: repositories
    repositories {
    ^
build.gradle.kts:19:9: error: unresolved reference: google
        google()
        ^
build.gradle.kts:20:9: error: unresolved reference: jcenter
        jcenter()
        ^
build.gradle.kts:23:5: error: unresolved reference: ext
    ext {
    ^
build.gradle.kts:24:9: error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
@InlineOnly public inline operator fun <K, V> MutableMap<String, String>.set(key: String, value: String): Unit defined in kotlin.collections
@InlineOnly public inline operator fun kotlin.text.StringBuilder /* = java.lang.StringBuilder */.set(index: Int, value: Char): Unit defined in kotlin.text
        set("kotlinVersion", "1.3.21")
        ^
build.gradle.kts:28:1: error: unresolved reference: tasks
tasks.register("clean", Delete::class ) {
^
build.gradle.kts:28:25: error: unresolved reference: Delete
tasks.register("clean", Delete::class ) {
                        ^
build.gradle.kts:29:5: error: unresolved reference: delete
    delete(rootProject.buildDir)
    ^
build.gradle.kts:29:12: error: unresolved reference: rootProject
    delete(rootProject.buildDir)
s

snowe

05/08/2019, 8:58 PM
it's not recognizing it as a kotlin file for some reason. is this from the command line?
k

kevin.cianfarini

05/08/2019, 8:58 PM
this is not from the command line, this is from the IDE
s

snowe

05/08/2019, 8:58 PM
could you try cli?
k

kevin.cianfarini

05/08/2019, 8:58 PM
yes
ran
./gradlew clean && ./gradlew build
looks to be okay so far
s

snowe

05/08/2019, 9:02 PM
👏🏽
k

kevin.cianfarini

05/08/2019, 9:03 PM
> Task :app:compileDebugKotlin
w: /home/kevin/code/android/Saddle/app/src/main/java/com/kevincianfarini/saddle/SaddleApplication.kt: (12, 14): 'appModule(AppModule!): DaggerAppComponent.Builder!' is deprecated. Deprecated in Java

> Task :app:compileReleaseKotlin
w: /home/kevin/code/android/Saddle/app/src/main/java/com/kevincianfarini/saddle/SaddleApplication.kt: (12, 14): 'appModule(AppModule!): DaggerAppComponent.Builder!' is deprecated. Deprecated in Java

> Task :app:lint
Ran lint on variant debug: 2 issues found
Ran lint on variant release: 2 issues found
Wrote HTML report to file:///home/kevin/code/android/Saddle/app/build/reports/lint-results.html
Wrote XML report to file:///home/kevin/code/android/Saddle/app/build/reports/lint-results.xml

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD SUCCESSFUL in 1m 3s
66 actionable tasks: 64 executed, 2 up-to-date
s

snowe

05/08/2019, 9:03 PM
🎉
k

kevin.cianfarini

05/08/2019, 9:03 PM
so, I'm still confused
s

snowe

05/08/2019, 9:03 PM
go to AS and run a gradle refresh
k

kevin.cianfarini

05/08/2019, 9:04 PM
works, still no dice
s

snowe

05/08/2019, 9:05 PM
ok, delete all your build directories. you can run clean inside AS or you can manually delete them.
k

kevin.cianfarini

05/08/2019, 9:05 PM
should I be worried about this?
warning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
s

snowe

05/08/2019, 9:06 PM
your kotlin plugin might be out of date?
k

kevin.cianfarini

05/08/2019, 9:06 PM
hmmm
s

snowe

05/08/2019, 9:06 PM
what version of gradle are you using?
k

kevin.cianfarini

05/08/2019, 9:07 PM
kotlin plugin
v1.3.21-release-Studio3.4-1
not quite sure how to check gradle version
is this relevant?
com.android.tools.build:gradle:3.4.0"
thanks for the help, this is my first time doing something non trivial with gradle
s

snowe

05/08/2019, 9:19 PM
gradle version will be in your gradle folder
gradle/wrapper/gradle-wrapper.properties
👍 1
I haven't done any android stuff so this is a first for me as well.
k

kevin.cianfarini

05/08/2019, 9:22 PM
using 5.1.1
also, I invalidated caches and restarted AS
works now
but I still can't just run the kotlin script
I have to do a full build, which is fine I guess?
s

snowe

05/08/2019, 9:26 PM
what do you mean you can't 'just run the kotlin script'?
k

kevin.cianfarini

05/08/2019, 9:27 PM
nevermind, it's still not downloading dependencies I add
and
s

snowe

05/08/2019, 9:27 PM
AS isn't?
or cli isn't?
k

kevin.cianfarini

05/08/2019, 9:30 PM
right clicking in the editor of the gradle file and clicking "run"
s

snowe

05/08/2019, 9:30 PM
that's not how gradle works.
k

kevin.cianfarini

05/08/2019, 9:30 PM
works fine via the CLI with gradle wrapper
figured it wasn't lol
s

snowe

05/08/2019, 9:30 PM
the gradle file isn't 'runnable'
you can use the tasks window in the Gradle panel
or you can click the elephant at the top there and type in the commands you want to run
do you have AS set to delegate to gradle?
k

kevin.cianfarini

05/08/2019, 9:32 PM
right okay, I was also doing that
It's still not resolving a dependency I just added to my module build.gradle
s

snowe

05/08/2019, 9:32 PM
not*?
k

kevin.cianfarini

05/08/2019, 9:32 PM
yes lol
s

snowe

05/08/2019, 9:32 PM
ok
you can run with
--refresh-dependencies
or you can hit the refresh button
you might need to turn on
auto import
k

kevin.cianfarini

05/08/2019, 9:34 PM
🤦‍♂️
duh
s

snowe

05/08/2019, 9:38 PM
so did that work?
k

kevin.cianfarini

05/08/2019, 9:38 PM
nope
just finished. Looked like the build was importing the dependencies but they're not showing up in the IDE
s

snowe

05/08/2019, 9:39 PM
like you're getting red text?
or you don't see them in the
external dependencies
section?
k

kevin.cianfarini

05/08/2019, 9:41 PM
I do they're there
what the heck is going on
Invalidated caches and it appeared
s

snowe

05/08/2019, 9:44 PM
yeah it just sounds like you're having environment issues. nothing is wrong with your build.gradle.kts
k

kevin.cianfarini

05/08/2019, 9:46 PM
yeah
thanks for all the help dude, I know that was super dumb lol
s

snowe

05/08/2019, 9:46 PM
haha, no problem. didn't take much away from my time so you're all good.
good luck!
k

kevin.cianfarini

05/08/2019, 9:50 PM
thanks