Questions tagged [gradle-kotlin-dsl]
Kotlin language support for Gradle build scripts.
1,198
questions
0
votes
0
answers
34
views
Executing a custom gradle task causes `Class Build_gradle.MyTask is a non-static inner class`
I am creating a custom task that will be registered in each module's build.gradle.kts file. I need maven-publish plugin for that. Here is how the task looks
abstract class MyTask : DefaultTask() {
...
0
votes
0
answers
7
views
Convert custom gradle file to gradle kts on Android project folder
Currently I have couple of custom gradle files in my project, example
jacoco.gradle when I tried to create a new/rename to jacoco.gradle.kts Android studio does not recognize the .kts file, I already ...
0
votes
0
answers
21
views
Intellij couldn't resolve gradle version
I just started learning gradle. Going right by guide, but when Intellij tries
to setup the project it fails, because it doesn't recognize gradle installed on my pc (I couldn't download it on every ...
1
vote
0
answers
18
views
How to sequentially start activities across different Android modules in Kotlin?
I have an Android project with two modules, let's call them Module A and Module B. In Module A, I have two activities, A and B. In Module B, I have an activity named X. I'm trying to achieve a ...
0
votes
1
answer
19
views
Using version catalog in Gradle Kotlin build for subprojects
I am migrating a Gradle multi module build from Groovy to Kotlin DSL and I would like make use of Gradle's static typed version catalogue.
// plugins declared in the settings.gradle.kts
subprojects {
...
0
votes
0
answers
13
views
Get the local file system path to the downloaded dependencies and plugins in build.gradle.kts
I have added the grpc protobuf kotlin dependencies and plugins into my build.gradle.kts
like this
dependencies {
implementation("io.grpc:grpc-kotlin-stub:${project.ext["grpcKotlinVersion&...
0
votes
0
answers
90
views
Inconsistent JVM-target compatibility detected for tasks despite already defining jvm ver
I'm running a flutter project and recently updated a bunch of dependencies.
I'm getting this error:
* What went wrong:
Execution failed for task ':flutter_google_places_sdk_android:compileDebugKotlin'....
0
votes
0
answers
8
views
In Gradle KotlinScript DSL, how to import generated class accessors like `implementation`?
Assuming that a Gradle kt file under <root>/buildSrc requires a class accessor:
/**
* Adds a dependency to the 'implementation' configuration.
*
* @param dependencyNotation notation for the ...
1
vote
1
answer
36
views
+50
publishing to maven central after loading all properties from a secret file/environment
I am getting various kinds of error when i tried to use the following script for publishing to maven central.
import java.util.Properties
plugins {
id("org.jetbrains.kotlin.jvm")
id(...
0
votes
0
answers
23
views
Why do I need kotest-framework-engine in the main sourceSets?
Through trial and error I've managed to setup kotest for a Kotlin Multiplatform desktop application, but I'm not quite sure I know what I'm doing. I thought that I need the test dependencies only in ...
1
vote
1
answer
62
views
Loader Constraint Violation for class io.grpc.Channel when trying to create ManagedChannel for GRPC Request
I'm trying to setup grpc client to make inference requests to Nvidia Triton inference server (version:23.06-py3) in Kotlin for my project.
I've setup protoc code generation using gradle (attached ...
0
votes
1
answer
12
views
Mixing Groovy and Kotlin DSL - how to access extra function
I have an older script which defines a function as such:
ext.someFunction = {
return true
}
And I have a new project that uses Kotlin DSL. Now I would like to use that function defined in the ...
0
votes
1
answer
15
views
Run a test based off the class name in a multi-project gradle project without specifying the project
Here is a simplified version of the project:
/root
-- /project1
--- /CoolPackage
---- /tests
---- MyTest.kt
-- /project2
--- /NotCoolPackage
---- /tests
---- TheOtherTest.kt
We have ...
1
vote
0
answers
24
views
Cannot import dependency even after declaring it in build.gradle.kts
I'm starting a new project using Kotlin/Native. Everything works great, but now I've decided that I want the ImmutableDoubleArray class from guava. So I have included the dependency in my build.gradle....
0
votes
1
answer
30
views
Android Studio Lint Warning: Unstable @Incubating
After migrating from Groovy to Kotlin DSL the settings.gradle is now getting a lint warning about the usage of this code
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
0
votes
1
answer
56
views
Set different versionCode for different flavors dimension combination [Kotlin DSL]
In my app I have 2 dimensions "app" and "server" and in that I have 4 flavors. Now I want to have different versionCode for different flavor combination.
For Example:-
For ...
0
votes
0
answers
14
views
I can't use extended attributes in gradle.kts
I created the gradle plugin using kotlin
But I can't use extended attributes in app/build.gradle.kts
I hope I can set the properties in build.gradle.kts and have them accessible in the plugin this is ...
0
votes
1
answer
88
views
Android Build Failure: Mismatch Between Kotlin 1.9.0 and Compose Compiler Extension 1.4.3
I'm working on an Android project using Jetpack Compose and I have encountered a compatibility issue between Kotlin and Compose. Despite following the compatibility map and adjusting my versions ...
0
votes
0
answers
21
views
Access variable from another gradle task
I have 2 task , I want to access variable from dependent task, But its giving null value
task test1(type: Exec) {
doFirst {
def serviceUrl = "dummyUrl"
rootProject.ext["...
0
votes
0
answers
41
views
Android Studio Error: 2 files found with path ‘kotlin/internal/internal.kotlin_builtins’
I’m working on an Android project using Kotlin and I’ve encountered an issue that I can’t seem to resolve. When I try to build my project, I get the following error:
2 files found with path 'kotlin/...
0
votes
1
answer
44
views
I am new to android studio and I'm trying to run an android source code I downloaded from github but i still keep getting errors
build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.a99460.smartnote"
...
0
votes
1
answer
27
views
In Gradle Kotlin script (kts) DSL, how to make a function usable in other scripts?
Assuming that I have a Kotlin script under buildSrc:
// buildSrc/src/main/kotlin/greet.gradle.kts
fun Project.greet(greeting: String) {
println("$greeting from ${this.name}")
}
I want ...
0
votes
0
answers
24
views
Why testOptions is marked unstable with @Incubating? Any action needed for warning?
I see warning on top of testOptions. Is it important warning that I should take an action? Anyone knows?
build.gradle.kts:
testOptions {
animationsDisabled = true
unitTests.apply {
...
0
votes
2
answers
60
views
The package name in the AndroidManifest.xml is overridden by applicationId in build.gradle. How to avoid this?
The package name in the AndroidManifest.xml is overridden by applicationId in build.gradle. How to avoid this. I merely want to change my ApplicationID, but it overrides the package in Manfiest file. ...
0
votes
0
answers
22
views
viewbinding: android.defaults.buildfeatures vs. buildFeatures{}?
What is the difference between:
android.defaults.buildfeatures.viewbinding=true
in gradle.properties
vs.
buildFeatures{ viewBinding true }
in app build.gradle.kts
?
Is the former preferred over ...
2
votes
0
answers
44
views
In Gradle 8 (build system) Kotlin DSL, should a convention plugin be defined under `buildSrc` or `build-convention` directory?
I've seen both cases in official samples:
under buildSrc:
https://docs.gradle.org/current/samples/sample_convention_plugins.html
as:
.
├── buildSrc
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
...
0
votes
0
answers
21
views
In Gradle 8 (build tool) kts DSL, how to split sections that depends on KotlinBuildScript and plugins in a `build.gradle.kts` file into another file?
Assuming that several Gradle projects are sharing the same plugin & buildScript settings:
buildscript {
repositories {
// Add here whatever repositories you're already using
...
0
votes
0
answers
29
views
Published gradle subproject depending on other subproject tries to resolve subproject to publication
I have the following gradle project structure:
repo:
library
sharedlibrary
where library and sharedlibrary are subprojects
library depends on sharedlibrary
library publishes to githubpackages using ...
17
votes
3
answers
3k
views
How to resolve the Gradle Build Error: java.lang.NoSuchMethodError
I am trying to build my project but every time I get the following errors:
Error 1
java.lang.NoSuchMethodError: 'kotlin.sequences.Sequence com.google.devtools.ksp.processing.Resolver....
0
votes
1
answer
148
views
How to add dependencies for Room in Android Studio?
I'm following an official tutorial to use Room for data persistence in Android Studio: https://developer.android.com/codelabs/basic-android-kotlin-compose-practice-bus-schedule-app
When adding the ...
0
votes
1
answer
190
views
Why apps made in Jetpack compose are larger. Any Solution?
Why apps made in compose are too much larger in size, the same app that had been made using xml is around 5-6mb but in compose it's going around 20mb why is there any option that I need to enable or ...
1
vote
1
answer
65
views
Gradle "could not resolve project" even though paths set correctly
I have this folder structure:
├── build.gradle.kts
├── processor
│ ├── build.gradle.kts
├── processor-api
│ ├── build.gradle.kts
├── settings.gradle.kts
└── src
├── main
└── test
This is ...
1
vote
0
answers
102
views
Unable to make progress running work - Android Studio
Android Studio Iguana | In the 2023.2.1 Canary 7 version, this error occurs at the end of the build.
For example, it can be verified that this is happening in the Now Android project created by Google....
0
votes
0
answers
44
views
How can I access a class inside a project from build.gradle.kts?
I have a project with several classes, one of the classes has a method that generates a json file and returns it, and I want to call this method in build during the build of the project.gradle.kts, ...
0
votes
2
answers
316
views
'androidx.emoji2:emoji2:1.4.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs
The project stopped building after importing import androidx.compose.ui.draw.alpha
SDK everywhere 33, it shows a dependency conflict
Error log:
An issue was found when checking AAR metadata:
1. ...
0
votes
1
answer
145
views
Gradle cannot resolve `java` in composite build + version catalog
I am in the process of creating a minimal example of gradle version cataloge plus build logic defined in a composite build. The basic setup is working so far. But for some reason I cannot gradle to ...
3
votes
0
answers
92
views
Why does upgrading to AGP 8.3.0-alpha06 make build fail with "No value passed for parameter 'providers'"
I have upgraded my android studio version to
Android Studio Iguana | 2023.2.1 Canary 6
Build #AI-232.9921.47.2321.10875067, built on September 28, 2023
Runtime version: 17.0.8+0-17.0.8b1000.22-...
0
votes
0
answers
79
views
Import Kotlin file to build.gradle.kts
In my Android project I am trying to figure out how to import a Kotlin file from a build-logic module to my app.
The application module is called mobile, resides in an app folder (→ app:mobile) and ...
0
votes
0
answers
19
views
Espresso Testing UI in androidTests Fails when run on Gradle ManagedDevice
I have a UI test that when I run it on an emulator or real device it works. When I run it on the gradle managed device it fails.
I have a list of items that I click on in NestedScrollView. About 2/3 ...
0
votes
0
answers
69
views
Spring Cloud Contract Test + Gradle + Kotlin DSL : Contracts are not found
Error facing while running ./gradlew build
* What went wrong:
Execution failed for task ':copyContracts'.
> Contracts could not be found: []
Please make sure that the contracts were defined, or ...
1
vote
1
answer
47
views
What do the backticks in build.gradle.kts do?
I have the following in my build.gradle.kts Gradle build file:
plugins {
`kotlin-dsl`
id("org.jetbrains.kotlin.jvm") version "1.6.10"
id("maven-publish")
`...
1
vote
1
answer
47
views
Gradle not waiting for scanner using System.in
I'm trying to run my project with gradle Kotlin 8.2 and instead of waiting for a user input on scanner it simply gives me this error
"Exception in thread "main" java.util....
0
votes
1
answer
21
views
my gradle in android studio doesn't work anymore
when I wanted to add a dependencie gradle got a problem in my gradle
I mean when I create a new project this problem there is in other project
I removed gradle and install the gradle again to solved ...
0
votes
0
answers
47
views
How to publish Gradle project to MavenLocal that depends on another local project
I'm working on an Android library, but this is most likely not Android specific.
I have a library project (mylib), that depends on another library project (myotherlib). Now if I publish my project to ...
1
vote
1
answer
103
views
How to apply a gradle plugin from maven
I'm learning using gradle (using kotlin).
I find it is easy to create a gradle plugin from template.
But I am still not able to understand. I have two question:
Did I publish my plugin correctly?
How ...
1
vote
0
answers
108
views
Share part of android section between multiple `build.gradle.kts` files
I would like to share some parts of build.grade.kts between android project.
For the moment, I have a library and an application, which have the same signingConfigs and buildTypes declaration. Later, ...
0
votes
1
answer
33
views
Enable viewBinding for multiple modules in Android
To enable viewBinding , for single module, we can set :
android {
...
buildFeatures {
viewBinding = true
}
}
Inside the module:Gradle *kts file.
Is it possible to enable ...
0
votes
0
answers
90
views
FATAL EXCEPTION: main java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY`
i hope you can find my text cause i really confused with my project because the app can't installed in emulator. I wish your advice and guidance.
this the Logcat when running the app
FATAL EXCEPTION: ...
0
votes
1
answer
105
views
Cannot choose between the following variants of
I am writing update4j based app. But I am facing build issue after adding some JavaFX dependencies.
build.gradle.kts:
plugins {
application
kotlin("jvm") version "1.8.21"
...
0
votes
0
answers
61
views
android studio 2022.3.1.19 windows Could not resolve all files for configuration Error
I use android studio 2022.3.1.19 the latest update for windows
I started the first project from "Empty Views Activity", I would say that I don't have any Error if I choose "Empty ...