I've been trying to migrate from the experimental version of coroutines (0.23.4) to the recently released one (1.0.1).
I also changed my version of Kotlin from 1.2.60 to 1.3.10.
I updated all of the import statements and removed the "experimental" bit from the gradle file.
When I try to compile my project, I get the following error:
Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class some.package.SomeClassName, unresolved supertypes: kotlinx.coroutines.CoroutineScope
SomeClassName doesn't even contain any reference to a coroutine -- it merely calls a method from a different module which in turn deals with some coroutines.
I tried adding the dependency on the coroutine packages to all of my gradle modules but that didn't help.
The only thing I found that describes a similar problem is this
but I can't understand how that would help or why my compilation fails anyway.
Any help please?
I had the same problem and it was happening because I was implementing the CoroutineScope in my "core" module and extending the class in the "app" module, which didn't have the coroutines import in build.gradle. Adding the import there as well fixed the problem.
Related
Is it possible to import classes from kotlinx package in a simple Kotlin script?
myscript.kts:
import kotlinx.serialization.*
import kotlinx.serialization.json.*
println("")
Running the above script with kotlinc -script myscript.kts gives this error:
error: unresolved reference: kotlinx
When I checked kotlinc/lib/ directory, there exists kotlinx-coroutines-core.jar and so on.
I am using Kotlin compiler version 1.4.0.
You can execute kotlin like a simple bash script with dependencies if you change the name to *.main.kts
https://raw.githubusercontent.com/yschimke/okurl-scripts/master/commands/tube-status.main.kts
$ ./tube-status.main.kts
Good Service
Good Service
Minor Delays
Part Closure
Minor Delays
Good Service
Minor Delays
Good Service
Part Closure
Good Service
Planned Closure
First of, the imports you have are related to the kotlin serialization library not the coroutines one.
As for running your script you need to specify the dependencies to the compiler. You can run your script like this :
kotlinc -script myscript.kts -classpath kotlinx-serialization-runtime-0.20.0-1.4.0-rc-95.jar
I've used the old kotlin serialization runtime but you'll need to adapt the command to your needs.
I'd like to define a Kodein-DI module in common Kotlin code (so I could import it from both JS and JVM modules).
What Gradle dependency should I add to commonMain?
My issue seems to be solved, see https://github.com/Kodein-Framework/Kodein-DI/issues/177#issuecomment-457915559 for details.
I have two modules - core and auth. In auth module I am trying to integrate Google Sign In to Firebase. All dependencies resolving correctly, but not a GoogleSignInClient. I don't want use dagger for this entity to provide this client somewhere. I want to use it only in this class. But dagger shows me an error :
class file for com.google.android.gms.auth.api.signin.GoogleSignInClient not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.android.gms.auth.api.signin.GoogleSignInClient not found
e: D:\Projects\<project path>\build\tmp\kapt3\stubs\internalProductionDebug\<class path>\di\components\AppComponent.java: error:
[ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
Unfortunately it wasn't dagger problem. It happens with using several Android modules when you use api and implementation in gradle incorrectly.
I don't know why, but when I fixed my dependencies in Gradle - all become working.
I am working on a project using kotlinjs for nodejs and I start to learn coroutines and integrate them into my code to say goodbye to the callback hell.
I managed to get coroutines working, my code can be compiled and executed, everything seems fine.
...except: The IDE still shows me errors. It seems to be confused by the additional libraries I added in order to get coroutines running.
I am currently fiddling around with the library dependencies, sometimes some errors go away, but then some code gets red which was okay before...
This is what I see:
Case 1:
Cannot access class 'kotlinx.coroutines.experimental.CoroutineContext'. Check your module classpath for missing or conflicting dependencies
Case 2:
Unresolved reference: JsModule
Modifier 'external' is not applicable to 'class'
You see, launch is recognized when I add the stdlib, but then the IDE complains with the other two errors.
Again, please note: In both cases, actual compilation is successful!
I am using IntelliJ 2018.1 with Kotlin Plugin 1.2.41.
Thanks to Alexander Chernikov at youtrack.jetbrains I could resolve my problem.
I cite his explanation:
The issue is that JavaScript libraries should be marked with special attribute to be recognized.
When they are imported from pom.xml or build.gradle, this mark is set, so the feature works.
In your project they are not marked.
At the moment, to correct the libs manually, please open .idea/libraries/org_jetbrains_kotlin_kotlin_stdlib_js_1_2_41.xml and .idea/libraries/org_jetbrains_kotlinx_kotlinx_coroutines_core_js_0_22_5.xml.
In both files find type="repository" and replace it with type="kotlin.js".
Make sure IDEA sees the change. (You can exit IDEA, make the change and restart.)
Then you can keep only these two libs in dependencies. The editor should work.
Here is the issue link:
https://youtrack.jetbrains.com/issue/KT-24575
There I have also attached a sample project with the problem.
When calling new JScrollPane, I was prompted to use a JBScrollPane.
com.intellij.ui.components.JBScrollPane
But when I do import com.intellij.ui.components.JBScrollPane, the compilation triggered an error.
error: cannot find symbol
import com.intellij.ui.components.JBScrollPane;
I tried adding this repository artifact, but it doesn't work.
This inspection is supposed to be shown only in the code of IntelliJ itself and IntelliJ plugins; if you saw it in a regular Swing project, it's a bug.
IntelliJ components can be adapted to be used outside of IntelliJ, but they are not packaged and published in a way that makes it easy.