Fixed
Status Update
Comments
zt...@gmail.com <zt...@gmail.com> #3
Fixed in 1.1.4-2 release of Kotlin
zt...@gmail.com <zt...@gmail.com> #4
just kidding, no it wasn't!
je...@google.com <je...@google.com>
ca...@agilefreaks.com <ca...@agilefreaks.com> #5
I can confirm is not fixed in 1.1.4-2 release
be...@google.com <be...@google.com> #6
This seems to be an issue with our sync code.
For a start, the version of Kotlin plugins in build.gradle and the IDE should be in sync, so one needs to manually go to settings and install the 1.1.4 version of the IDE plugin. Even this things don't work unfortunately.
The Kotlin plugin for Gradle used to copy class files from $buildDir/kotlin-classes into $buildDir/classes/java. It's no longer doing that, the classes are only under $buildDir/classes/kotlin and it seems nothing on the IDE side knows about it.
Lucas - is this something our code for handling pure-java modules should handle?
For a start, the version of Kotlin plugins in build.gradle and the IDE should be in sync, so one needs to manually go to settings and install the 1.1.4 version of the IDE plugin. Even this things don't work unfortunately.
The Kotlin plugin for Gradle used to copy class files from $buildDir/kotlin-classes into $buildDir/classes/java. It's no longer doing that, the classes are only under $buildDir/classes/kotlin and it seems nothing on the IDE side knows about it.
Lucas - is this something our code for handling pure-java modules should handle?
ls...@google.com <ls...@google.com> #7
I am not sure. I believe we inherit pretty much everything of pure-java modules from Intellij.
It seems to me that we are missing a kotlin model where we could query these things.
It seems to me that we are missing a kotlin model where we could query these things.
sp...@google.com <sp...@google.com>
ca...@agilefreaks.com <ca...@agilefreaks.com> #8
it is working in 1.1.4-3!
be...@google.com <be...@google.com> #9
I can see it broken with 1.1.4-3 (build.gradle) and v1.1.4-release-Studio3.0-3 (AS), both 3.0.0-beta4 and studio-master-dev.
We've discussed this briefly with Tor and it seems that our sync mechanism for non-android modules needs to supporthttps://docs.gradle.org/4.0/release-notes.html#multiple-class-directories-for-a-single-source-set . Alex, you probably understand this best?
We've discussed this briefly with Tor and it seems that our sync mechanism for non-android modules needs to support
be...@google.com <be...@google.com> #10
I tried to check how this is handled in non-Android projects, but it seems that IJ just compiles the sources on its own, putting the output in out/, not reusing Gradle's compilation output.
al...@google.com <al...@google.com>
al...@google.com <al...@google.com> #11
I looked at this and it is broken in more than one place:
1. Android Studio is not setting the output paths correctly for non-Android projects. I have a fix for that, and I will create a separate bug.
2. The IDE only supports 1 output folder path. After fixing #1, it will ${build}/main/java. We cannot add ${build}/main/kotlin because it is a single value, not a list.
Now, we have these options:
1. Change the kotlin plugin to put stuff in ${build}/main/java. I don't think this is the right thing to do.
2. Run tests through the Tooling API. This is the right fix, but we are not there yet.
3. Manually copy ${build}/main/kotlin into ${build}/main/java when running a test from the IDE.
So far #3 is the one that I consider the winner. Thoughts?
1. Android Studio is not setting the output paths correctly for non-Android projects. I have a fix for that, and I will create a separate bug.
2. The IDE only supports 1 output folder path. After fixing #1, it will ${build}/main/java. We cannot add ${build}/main/kotlin because it is a single value, not a list.
Now, we have these options:
1. Change the kotlin plugin to put stuff in ${build}/main/java. I don't think this is the right thing to do.
2. Run tests through the Tooling API. This is the right fix, but we are not there yet.
3. Manually copy ${build}/main/kotlin into ${build}/main/java when running a test from the IDE.
So far #3 is the one that I consider the winner. Thoughts?
al...@google.com <al...@google.com> #12
Now, until we can run test through the Tooling API, we need to:
1. Try to copy ${build}/main/kotlin into ${build}/main/java. Timing is important, this needs to be done after the build but before running the test.
2. If #1 is not possible, would it be possible to change the build output for Kotlin to ${build}/main/java in the project's build.gradle file? If so, we can document this issue as a "known bug" with the workaround.
Assigning bug to Lucas.
be...@google.com <be...@google.com> #13
We're already working around the "single output dir" limitation in AndroidJUnitPatcher, to add resources to the classpath. If only we knew (in the model) all the classfiles directories, we can add handle them in the same way.
[Deleted User] <[Deleted User]> #14
If you will decide to post this "known bug" workaround, don't forget to note about TEST output for kotlin modules as well, it is also broken for running module's tests from IDE.
ls...@google.com <ls...@google.com> #15
Fix will be in Beta 6. Thank you Michal!
r....@gmail.com <r....@gmail.com> #16
I've tried beta 6, but still doesn't work. With the following workaround I get it to work
subprojects { subproject ->
afterEvaluate {
if (subproject.plugins.hasPlugin("kotlin") && subproject.plugins.hasPlugin("java-library")) {
subproject.kotlin.copyClassesToJavaOutput = true
subproject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
subprojects { subproject ->
afterEvaluate {
if (subproject.plugins.hasPlugin("kotlin") && subproject.plugins.hasPlugin("java-library")) {
subproject.kotlin.copyClassesToJavaOutput = true
subproject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
be...@google.com <be...@google.com>
ca...@agilefreaks.com <ca...@agilefreaks.com> #17
Same thing here, tests from java/kotlin modules get class not found, and android test that use those modules get class not found.
I also have a very strange mockito issue where it complains it can't mock interfaces starting from the beta6 update, might be related.
I also have a very strange mockito issue where it complains it can't mock interfaces starting from the beta6 update, might be related.
ca...@agilefreaks.com <ca...@agilefreaks.com> #18
I should mention that the subproject workaroud works (for he mockito issue also)
ls...@google.com <ls...@google.com> #19
Apologies, the fix should be in Beta 7.
al...@google.com <al...@google.com> #20
Should we close the bug then?
ls...@google.com <ls...@google.com> #21
Yes. We have bug b/65574885 for tracking a definitive solution with a kotlin model for gradle.
yo...@gmail.com <yo...@gmail.com> #22
can you make b/65574885 open to the public so we can follow along? :)
ra...@gmail.com <ra...@gmail.com> #23
What should we expect with Beta 7? Will gradle and IDE classpaths be synced? Right now I have to copy kotlin classes before running the tests.
bi...@gmail.com <bi...@gmail.com> #24
Same with Beta6, only solution found is copy of kotlin classes
https://youtrack.jetbrains.com/issue/KT-17951
subprojects { subProject ->
afterEvaluate {
if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
subProject.kotlin.copyClassesToJavaOutput = true
subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
subprojects { subProject ->
afterEvaluate {
if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
subProject.kotlin.copyClassesToJavaOutput = true
subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
ls...@google.com <ls...@google.com> #25
@Michal, reassigning to you, since fix is yours and then you can probably answer better what to expect.
bi...@gmail.com <bi...@gmail.com> #26
Just upgraded to android studio 3.0 beta 7, removed the copy task. checked local unit test and instrumentation test. Everything seems to work fine
r....@gmail.com <r....@gmail.com> #27
Issue is also fixed for us with beta 7.
ra...@gmail.com <ra...@gmail.com> #28
Can we make b/65574885 public please?
Description
all required information.
Studio Build:
Version of Gradle Plugin: 3.0.0-beta2
Version of Gradle: 4.1-rc-1
Version of Java: 1.8
OS:
External kotlin module is not being properly included with kotlin version 1.1.4. Using Kotlin version 1.1.3-2 fixes the issue
Steps to Reproduce:
1. Run "BugTest.kt" from Android Studio (click play button within class)
2. See crash below. This is a result of the kotlin class in `:lib` not being properly included in `:app` when running a test from Android Studio. Note: Java class works fine, and this issue is NOT present when running from command line `./gradlew test` works!
Demo project replicating the issue is attached.
Picked up JAVA_TOOL_OPTIONS: -Xmx8096m -XX:+HeapDumpOnOutOfMemoryError
java.lang.NoClassDefFoundError: bug/kotlin/example/com/lib/Some
at bug.kotlin.example.com.myapplication.ExampleUnitTest.this_is_the_bug(ExampleUnitTest.kt:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.ClassNotFoundException: bug.kotlin.example.com.lib.Some
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 28 more
Changing kotlin version to 1.1.3-2 fixes the issue.