joreilly / PeopleInSpace

Kotlin Multiplatform sample with SwiftUI, Jetpack Compose, Compose for Wear, Compose for Desktop, and Compose for Web clients along with Ktor backend.
Apache License 2.0
2.98k stars 263 forks source link

project import failed in a newly installed AS 4.2 canary 8 (Ubuntu) #8

Closed odifek closed 3 years ago

odifek commented 4 years ago

Project import fails with error Please initialize at least one Kotlin target in 'common (:common)'.

OS: Ubuntu Linux 20.04

Android Studio Version: 4.2 Canary 8. (No multiplatform project has been done before now)

Clicking Run with --debug option returns this error. Caused by: org.gradle.internal.component.AmbiguousConfigurationSelectionException: The consumer was configured to find a runtime of a library compatible with Java 14, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :common: Changing the default system jdk to java 8 prints the same message but now Java 8 instead of Java 14.

joreilly commented 4 years ago

I've tried importing it that way and also separately cloning and then opening project and haven't been able to reproduce yet (with same version of AS). Not sure if anyone else reading this has tried this on Linux (in case somehow that's a factor?)

joreilly commented 4 years ago

@VeryRoadTrip Just to also confirm you are using 4.2 Canary version as well? Lastly, have you been able to open other Kotlin Multiplatform project successfully?

joreilly commented 4 years ago

@odifek @VeryRoadTrip if you haven't already, can you also try to open another Kotlin Multiplatform project and see if you're having same issue (e.g. https://github.com/touchlab/KaMPKit)

joreilly commented 4 years ago

I asked in slack and @arkivanov mentioned he had seen same issue during migration to Kotlin 1.4 due to

js {
        browser {
        }
    }

Following is his fix.... @odifek @VeryRoadTrip could one of you check if this fixes issue for you (and perhaps open PR with fix :) )

https://github.com/arkivanov/MVIKotlin/blob/41a47c0fb022bc79312053d7605f83a02e1b5df7/sample/todo-app-js/build.gradle.kts#L47

I think we should just need "browser"()

arkivanov commented 4 years ago

@joreilly Just tried by myself. The error is there, the suggested fix does not help.

odifek commented 4 years ago

I found this issue opened by Zac Swears. But I am not yet able to make sense of the discussion. https://github.com/gradle/gradle/issues/12126

joreilly commented 4 years ago

@arkivanov believes issue might be related to cocoapods plugin. @odifek @VeryRoadTrip could you try opening https://github.com/touchlab/KaMPKit and see if you see same issue (it also uses that plugin)

arkivanov commented 4 years ago

@joreilly KaMPKit opens fine. But it uses another plugin: co.touchlab.native.cocoapods

odifek commented 4 years ago

That's correct. KaMPKit runs fine on my system also

joreilly commented 4 years ago

alpha11 just out....just in case this somehow resolves this issue?

martinbonnin commented 4 years ago

For what it's worth, I can synchronize correctly with AGP 4.2.0-alpha12

darran-kelinske-fivestars commented 4 years ago

I am having the same issue on canary - i can build the web browser target using gradle, but the android build.gradle.kts is not being recognized.

joreilly commented 4 years ago

@darran-kelinske-fivestars is this also on linux?

darran-kelinske-fivestars commented 4 years ago

yes sir - on the latest ubuntu - tried java 8 and 11 as the project sdk

joreilly commented 4 years ago

Unfortunately I don't have a linux setup to test this on....if anyone here is able to diagnose and create PR that would be great

darran-kelinske-fivestars commented 4 years ago

what OS are you running?

On Thu, Nov 19, 2020 at 1:29 PM joreilly notifications@github.com wrote:

Unfortunately I don't have a linux setup to test this on....if anyone here is able to diagnose and create PR that would be great

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joreilly/PeopleInSpace/issues/8#issuecomment-730588412, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY6HJ6LRY6W6YDXPP74IU3SQVWYDANCNFSM4QQ64NTA .

joreilly commented 4 years ago

macOS

dazza5000 commented 4 years ago

This fixed it for me on Ubuntu https://github.com/joreilly/PeopleInSpace/pull/14

joreilly commented 3 years ago

Curious if other folks that reported issues here using linux are seeing this resolved using canary 16 version?

darran-kelinske-fivestars commented 3 years ago

@odifek - any luck for you?

odifek commented 3 years ago

@darran-kelinske-fivestars yea. Works fine now on latest canary versions

joreilly commented 3 years ago

ok, going to close this for now and we can reopen if the issue resurfaces