Android Studio can't resolve androix.ui dependency although repository `google()` has been added - kotlin

I am kind of frustated. I want to use the androidx.ui dependency but gradle denies to download it.
Here is my build.gradle.kts file:
import org.jetbrains.compose.compose
plugins {
kotlin("jvm") version "1.4.0"
id("org.jetbrains.compose") version "0.1.0-m1-build62"
}
buildscript {
repositories {
jcenter()
google()
mavenCentral()
maven { setUrl("https://maven.google.com") }
}
}
allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven { setUrl("https://maven.google.com") }
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
dependencies {
implementation(compose.desktop.currentOs)
implementation("androidx.ui:ui-tooling:1.0.0-alpha07")
}
compose.desktop {
application {
mainClass = "MainKt"
}
}
Error:
Could not resolve androidx.ui:ui-tooling:1.0.0-alpha07.
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Related

Kotlin NoSuchMethodError after installing a library that enables a plugin

I want to experience a library called arrow analysis
My build.gradle.kts file looks as follows:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.7.10"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
implementation("io.arrow-kt:arrow-core:1.1.2")
}
buildscript {
dependencies {
classpath("io.arrow-kt.analysis.kotlin:io.arrow-kt.analysis.kotlin.gradle.plugin:2.0")
}
}
apply(plugin = "io.arrow-kt.analysis.kotlin")
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
after an attempt to build the project, I get the following error:
java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.psi.KtExpression org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt.getReceiverExpression(org.jetbrains.kotlin.resolve.calls.model.ResolvedCall)'
at arrow.meta.plugins.analysis.phases.analysis.solver.ast.kotlin.KotlinResolvedCall.getReceiverExpression(KotlinResolvedCall.kt:37)
at arrow.meta.plugins.analysis.phases.analysis.solver.ResolvedCallUtilsKt.allArgumentExpressions(ResolvedCallUtils.kt:75)
at arrow.meta.plugins.analysis.phases.analysis.solver.ResolvedCallUtilsKt.arg(ResolvedCallUtils.kt:119)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.controlFlowAnyFunction(Expressions.kt:438)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.checkCallExpression(Expressions.kt:397)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.fallThrough(Expressions.kt:260)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.access$fallThrough(Expressions.kt:1)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt$checkExpressionConstraints$2.invoke(Expressions.kt:244)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt$checkExpressionConstraints$2.invoke(Expressions.kt:157)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
I checked the source code, and everything seems to be in place. Did I something wrong as per the instructions to install this library which is denoted as follows:
buildscript {
dependencies {
classpath("io.arrow-kt.analysis.kotlin:io.arrow-kt.analysis.kotlin.gradle.plugin:2.0")
}
}
apply(plugin = "io.arrow-kt.analysis.kotlin")
You need to apply the plugin inside the plugins block and in the same fashion you're applying the Kotlin JVM plugin.
They mention to use it like this on their official docs
plugins {
kotlin("multiplatform") version "1.6.21"
// other plugins
id("io.arrow-kt.analysis.kotlin") version "2.0.2"
}
buildscript {
repositories {
mavenCentral()
}
}

build.gradle file could not compile

This error appears when I run my project:
Could not compile build file 'H:\StartActivity\build.gradle'.
startup failed:
build file 'H:\StartActivity\build.gradle': 28: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.0-release-764"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.0-release-764'
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Changing ext.kotlin_version to 1.5.0 is working :)
You should move plugins{...} before allprojects{...}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.0-release-764"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.0-release-764'
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
....

maven-publish missing artifact to repository

II'm trying to publish my lib but i'm having some problems related to its publication.
I'm using this library https://github.com/vanniktech/gradle-maven-publish-plugin to publish my project on maven central (oss), but, this for some reason only -sources.jar, -javadoc.jar and .module are being pushed to the repository, however file-butler-0.1.4-SNAPSHOT.jar is missing :(
Does someone have any idea?
build.gradle(module)
plugins {
id 'java-library'
id 'kotlin'
id 'kotlin-kapt'
}
dependencies {
def gson = "com.google.code.gson:gson:2.8.6"
def moshi = "com.squareup.moshi:moshi:1.11.0"
def moshCodeGen = "com.squareup.moshi:moshi-kotlin-codegen:1.11.0"
implementation(Deps.core.kotlin)
implementation(gson)
implementation(moshi)
kapt(moshCodeGen)
testImplementation(Deps.testing.truth)
testImplementation(Deps.testing.jUnit)
kaptTest(moshCodeGen)
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'src/main/java'
}
apply plugin: "com.vanniktech.maven.publish"
build.gradle.kts(project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath(kotlin("gradle-plugin", "1.4.10"))
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.13.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task<Delete>("clean") {
delete(rootProject.buildDir)
}
ps: publishToMavenLocal publish the expected jar to my local repository.

error in build.gradle.kts script using extra property

below is a small (build.gradle.kts) script which gives at line 9 (the classpath line) the error : Cannot get property 'kotlinVersion' on extra properties extension as it does not exist
buildscript {
extra["kotlinVersion"] = "1.2.70"
repositories {
jcenter()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${extra["kotlinVersion"]}")
}
}
I do not understand why this error occur.
You must use "project.extra[...]" instead of "extra[...]"
buildscript {
extra["kotlin_version"] = "1.3.72"
repositories {
jcenter()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.extra["kotlin_version"]}")
}
}
This works for me:
buildscript {
extra["kotlin_version"] = "1.3.61"
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${extra["kotlin_version"]}")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}

Unable to resolve dependency for :Could not resolve org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.8.1-rc13

I am getting a gradle build error for unresolved dependencies in a Kotlin/Native sample project.
Failed to resolve: org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.8.1-rc13
my build.gradle (common module) looks like
apply plugin: 'kotlin-platform-common'
apply plugin: 'kotlinx-serialization'
repositories {
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
jcenter{ url "https://jitpack.io" }
jcenter()
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url "https://dl.bintray.com/sandwwraith/libs-preview/"}
mavenLocal()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
}
Build.gradle(platform-android level)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-platform-android'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.phonepe.mykotlinnativesample"
minSdkVersion 15
targetSdkVersion 27
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
def butterknife_version = '8.8.1'
repositories{
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
jcenter{ url "https://jitpack.io" }
jcenter()
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url "https://dl.bintray.com/sandwwraith/libs-preview/"}
mavenLocal()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "com.jakewharton:butterknife:$butterknife_version"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.dagger:dagger-android:2.16'
implementation 'com.google.dagger:dagger-android-support:2.16' // if you use the support libraries
kapt 'com.google.dagger:dagger-android-processor:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation 'com.android.support:exifinterface:27.1.1'
expectedBy project(":common")
}
Project level Build.gradle looks like:
apply plugin: 'kotlinx-serialization'
buildscript {
ext.kotlin_version = '1.3.0-rc-131'
ext.serialization_version = '0.8.1-rc13'
ext.serializationRepo = "https://dl.bintray.com/kotlin/kotlinx/"
ext.serialization_plugin_version="1.3.0-rc-131"
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://dl.bintray.com/sandwwraith/libs-preview/"}
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.9.2"
classpath "org.jetbrains.kotlin:kotlin-serialization:$serialization_plugin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://dl.bintray.com/sandwwraith/libs-preview/"}
mavenLocal()
}
}
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
}
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://dl.bintray.com/sandwwraith/libs-preview/"}
mavenLocal()
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle::
include ':android', ':common', ':myapplication'
enableFeaturePreview('GRADLE_METADATA')
What are the correct versions and repositories that I can use to be able to use serialization?
Setup you've attached is kinda strange, because you're applying Kotlin/Native's 'konan' plugin to the same module as 'kotlin-platform-common' plugin. First of all, 'konan' is deprecated and replaced with 'kotlin-platform-native'. Secondly, these plugins should be applied to different gradle modules, see kotlin multiplatform reference.
Regarding serialization, it now comes in two flavours: One, for Kotlin 1.2 has version numbers 0.6.x (0.6.2 for 1.2.70) and does not support Kotlin/Native; only separate json parser is provided instead. Second flavour, for Kotlin 1.3 is under development phase and has number 0.8.x-rc13 (latest one is 0.8.1-rc13 for Kotlin/Native 0.9.2) and it does contain K/N support in a separate artifact with coordinates "kotlinx-serialization-runtime-native". Serialization docs for Kotlin 1.3 preview reveal more information: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/eap13.md .
There is also a dedicated example of setup which contains a ready-to-use stub of multiplatform project with serialization. Branch native_preview uses aforementioned Kotlin 1.3-rc, K/N 0.9.2 and serialization 0.8.1.