Fixed
Status Update
Comments
ja...@gmail.com <ja...@gmail.com> #2
It's worth noting that this issue occurs on Mac as well. I have added a task to run from Gradle: `./gradlew startMain` which runs perfectly fine, so this seems to be an IDE issue and not anything with Gradle.
uc...@google.com <uc...@google.com>
xa...@google.com <xa...@google.com>
rp...@google.com <rp...@google.com>
rp...@google.com <rp...@google.com> #3
Note: Possibly a duplicate of bug 66084314
me...@gmail.com <me...@gmail.com> #4
meet same situation
me...@gmail.com <me...@gmail.com> #5
When I convert the version to gradle 3.3-all and gradle tool 2.3.3, it's ok. So should be android studio 3.0 bug
fo...@gmail.com <fo...@gmail.com> #6
I also encountered such a problem
rp...@google.com <rp...@google.com>
rp...@google.com <rp...@google.com> #7
Note: I was able to reproduce the bug. The issue is that the library package is not added to the JVM classpath when starting the debugger, hence the exception. It is currently somewhat difficult to diagnose the root cause, because it seems the offending code is inside the Kotlin plugin, and my setup does not currently allow me to step through the code.
rp...@google.com <rp...@google.com> #8
Note: This issue reproduces on Android Studio 3.0, 3.0.1 and 3.1 Canary.
vh...@google.com <vh...@google.com> #9
Is there a manual workaround?
rp...@google.com <rp...@google.com> #10
#9: Not that I know of. I need time to investigate more to figure out what is the root cause of the issue.
rp...@google.com <rp...@google.com> #11
Just chatted with alruiz about this. Since this is a gradle project, this bug should be assigned to the project system team.
rp...@google.com <rp...@google.com> #12
Note: The workaround mentioned in bug https://buganizer.corp.google.com/issues/64804587#comment24 solved the issue for me.
In the main gradle file, add the following section:
subprojects { subProject ->
afterEvaluate {
if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
subProject.kotlin.copyClassesToJavaOutput = true
subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
This is most certainly just a workaround for now, and this may have to be removed once the root cause is fixed.
In the main gradle file, add the following section:
subprojects { subProject ->
afterEvaluate {
if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
subProject.kotlin.copyClassesToJavaOutput = true
subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
This is most certainly just a workaround for now, and this may have to be removed once the root cause is fixed.
to...@gmail.com <to...@gmail.com> #13
when I do like #12 ,a new error occurs
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
vh...@google.com <vh...@google.com> #14
The workaround does not seem to fix the problem.
tn...@google.com <tn...@google.com> #15
Lucas, any ideas?
ls...@google.com <ls...@google.com> #16
Fix is waiting for review (http://ag/3529513 )
A more robust fix for us would depend on exposing the output folders in a Kotlin model. I'm talking to Jetbrains to check if I could upstream directly to the Gradle plugin
A more robust fix for us would depend on exposing the output folders in a Kotlin model. I'm talking to Jetbrains to check if I could upstream directly to the Gradle plugin
ls...@google.com <ls...@google.com> #17
Fix in commit 535a81b0842d14408114537a9ac97ba807189800
Will be in next canary versions of 3.2
Will be in next canary versions of 3.2
ya...@gmail.com <ya...@gmail.com> #18
Do you have plans to backport the bugfix to Android Studio 3.1?
ls...@google.com <ls...@google.com> #19
I think that is not the plan. However, the workaround of modifying your root gradle file to copy Kotlin outputs to java output folder should work.
jo...@gmail.com <jo...@gmail.com> #20
object print_text2 {
@JvmStatic
fun main(args: Array<String>) {
Tprint("fffffhi")
}
private fun Tprint(args: String) {
println(args)
}
}
Exception in thread "main" java.lang.ClassNotFoundException: gotopark.buster.ko_test.k1.print_text2
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:107)
@JvmStatic
fun main(args: Array<String>) {
Tprint("fffffhi")
}
private fun Tprint(args: String) {
println(args)
}
}
Exception in thread "main" java.lang.ClassNotFoundException: gotopark.buster.ko_test.k1.print_text2
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:107)
ls...@google.com <ls...@google.com> #21
Could you provide more details please? AS version, repro project example, Kotlin plugin version, etc
ko...@gmail.com <ko...@gmail.com> #22
3.2 canary 14, Gradle 4.7 + plugin 3.2.0-alpha-14, kotln 1.2.41+ plugin 1.2.41-release-Studio3.2.1 still not working
ho...@gmail.com <ho...@gmail.com> #23
With 3.2 Canary 15, running a Kotlin `main` function (either top-level or one inside an `object`) works only if the classes were previously compiled by a Gradle build.
Running the configuration does not trigger a Gradle build that would compile Kotlin, and so changed classes are not recompiled on running a `main` function.
Running the configuration does not trigger a Gradle build that would compile Kotlin, and so changed classes are not recompiled on running a `main` function.
rp...@google.com <rp...@google.com> #24
Opened b/80436109 to track the issue in 3.2 Canary 14 and 15 (from comments #22 and #23)
ls...@google.com <ls...@google.com> #25
This was fixed only for java/kotlin only modules. Thank you for catching this.
The mentioned bug will keep track for Android modules.
The mentioned bug will keep track for Android modules.
sf...@gmail.com <sf...@gmail.com> #26
I spent a lot of time thinking that my configuration was wrong, but when it can be repaired, it has been so long.
ls...@google.com <ls...@google.com> #27
Fix for Android Studio is provided in AS 3.2 Beta1. However there is still a non-deterministic failure which is a bug in Intellij Kotlin Plugin and we're working with them to fix it. Please refer to bug 80436109 to track that.
lu...@gmail.com <lu...@gmail.com> #28
have fixed now?
Description
AI-171.4402976, JRE 1.8.0_152-release-915-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 2560x1080, 1680x1050
When I create a new Java Library within my Android Studio project and add Kotlin, I can no longer run the Main class via "Right click -> Run" the method, it fails with the error "Error: Could not find or load main class com.commit451.lib.Main". The same configuration works in IntelliJ
Here is a link to a sample that reproduces this: