Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
Create:path/default/$/
au...@google.com <au...@google.com> #3
Are there any updates on when this should happen?
ga...@google.com <ga...@google.com> #4
I've updated the "Blocking Release" label now; we'd like to land it in AGP 8.1.
lu...@miquido.com <lu...@miquido.com> #5
ad...@guardian.co.uk <ad...@guardian.co.uk> #6
@#5: The blocking release has changed to 8.3 beta. Fingers crossed that it doesn't slip again.
jo...@gmail.com <jo...@gmail.com> #7
@#6 Well, it did :(
ph...@haspa-next.de <ph...@haspa-next.de> #8
ag...@digibank.co.il <ag...@digibank.co.il> #9
Would love more info, I'm especially waiting for Test Fixtures.
eu...@gmail.com <eu...@gmail.com> #10
Interesting, where do you read the release notes? I quickly tried the 8.3.0-alpha-17 AGP and the test fixtures are not working yet.
je...@google.com <je...@google.com> #11
the feature was indeed delayed to 8.4, but the good news is that someone is actually working on it right now so we are confident we will hit that release.
ja...@gmail.com <ja...@gmail.com> #12
ze...@gmail.com <ze...@gmail.com> #13
si...@adevinta.com <si...@adevinta.com> #14
AGP 8.5.0-alpha01 is out, and still no support for Kotlin test fixtures...
bl...@gmail.com <bl...@gmail.com> #15
nu...@traderepublic.com <nu...@traderepublic.com> #16
Any update on this please?
he...@ryanwebmail.com <he...@ryanwebmail.com> #17
je...@google.com <je...@google.com> #18
yes it is currently scheduled to be available in 8.5.0
ga...@linecorp.com <ga...@linecorp.com> #19
Also, can we expect to resolve
sp...@google.com <sp...@google.com>
eu...@gmail.com <eu...@gmail.com> #20
I've tried AGP 8.5-beta01 and it is not supported still :(
sp...@google.com <sp...@google.com> #21
Starting with AGP 8.5.0-beta01
, there is support for kotlin in testFixtures
sources. You can try it by adding android.experimental.enableTestFixturesKotlinSupport=true
to your gradle.properties
file.
Notes:
- Requires kotlin version 1.9.20 or higher
- There is not support for KAPT or KSP in
testFixtures
sources yet.
si...@gmail.com <si...@gmail.com> #22
I can confirm this works fine on 8.5.0-beta01 with the new experimental flag (see
One minor thing though, it currently forces us to add an explicit dependency on Kotlin's stdlib. This is automatically setup in regular Kotlin testFixtures. Is this something that needs to be added in a future version? (otherwise, adding it on the consumer code is
The corresponding stacktrace.
> Task :app:extractDebugTestFixturesAnnotations FAILED
Execution failed for task ':app:extractDebugTestFixturesAnnotations'.
> Error while evaluating property 'hasAndroidAnnotations' of task ':app:extractDebugTestFixturesAnnotations'.
> Could not resolve all dependencies for configuration ':app:debugTestFixturesCompileClasspath'.
> Kotlin standard library is missing from debugTestFixturesRuntimeClasspath. Please add a dependency on
"org.jetbrains.kotlin:kotlin-stdlib:1.9.24" to your build file: `file:/Android-TestFixtures/app/build.gradle.kts`
pa...@gmail.com <pa...@gmail.com> #23
Nice to heart that #21!
Re auto-adding the dependency, hopefully AGP will adhere to what KGP is doing:
i.e. if it auto-adds, it'll be possible to disable that with kotlin.stdlib.default.dependency=false
eu...@gmail.com <eu...@gmail.com> #24
Wow! With the provided flag and testFixturesCompileOnly "org.jetbrains.kotlin:kotlin-stdlib:1.9.24"
it works for me also!
`
sp...@google.com <sp...@google.com> #25
Thanks for the feedback.
Requiring an explicit dependency on Kotlin's stdlib was intentional, but I filed
si...@adevinta.com <si...@adevinta.com> #26
Another issue that we are seing in a large project, is the missing Compose runtime library that is seemingly required on the testFixtures compilation classpath for an Android module that is depending on Compose (and correctly configured with the Compose BoM). I'm not sure why it is needed though.
Here is the stacktrace:
> Task :lib:compileDebugTestFixturesKotlin FAILED
e: androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found. The compose compiler plugin you are using (version 1.5.14) expects a minimum runtime version of 1.0.0.
at androidx.compose.compiler.plugins.kotlin.VersionChecker.noRuntimeOnClasspathError(VersionChecker.kt:195)
at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:168)
at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:81)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda$1(JvmIrCodegenFactory.kt:225)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:107)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:255)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:59)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:224)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:463)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:62)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:477)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:400)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:281)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:125)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:657)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:105)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1624)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:714)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
* What went wrong:
Execution failed for task ':lib:compileDebugTestFixturesKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
sp...@google.com <sp...@google.com> #27
Re: #26, can you give repro steps?
si...@gmail.com <si...@gmail.com> #28
AGP 8.5 is now released as stable 🙌
I'll try to reproduce the issue with Compose runtime dependency and report back if we still hit this.
ke...@gmail.com <ke...@gmail.com> #29
There is not support for KAPT or KSP in testFixtures sources yet.
Is this planned any time soon?
sp...@google.com <sp...@google.com> #30
There is not support for KAPT or KSP in testFixtures sources yet.
Is this planned any time soon?
Yes. AGP version TBD
d....@gmail.com <d....@gmail.com> #31
Hi, I've tried testFixtures, but got some IDEA error inside kotlin class (using Android Studio Koala | 2024.1.1):
Cannot inline bytecode built with JVM target 17 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
The toolchain is configured, so my jvmTarget is set properly. kotlin-stdlib also included in testFixtures sourceSet.
si...@gmail.com <si...@gmail.com> #32
Here are the reproduction steps with the android/nowinandroid project.
Using this testFixturesImplementation(libs.androidx.compose.runtime)
in core/analytics/build.gradle.kts
You can then execute the following compilation task to check the error: ./gradlew :core:analytics:compileDemoDebugTestFixturesKotlin --rerun-tasks
za...@gmail.com <za...@gmail.com> #33
FYI, this doesn't appear to work at all in a multiplatform project, even for just android targets. Not sure if that should be an issue here or filed separately on youtrack?
si...@gmail.com <si...@gmail.com> #34
Yahor Berdnikau Commented 8 months ago
Note that Gradle Test Fixtures plugin is only available for JVM.
za...@gmail.com <za...@gmail.com> #35
If you use the kotlin.jvm plugin, yes. But if you use a kotlin.multiplatform project with a JVM target, the test fixtures plugin doesn't understand this as it uses/produces differently named artifacts.
sp...@google.com <sp...@google.com> #36
FYI, this doesn't appear to work at all in a multiplatform project, even for just android targets. Not sure if that should be an issue here or filed separately on youtrack?
Can you file a separate bug with more info?
za...@gmail.com <za...@gmail.com> #37
Here or on youtrack? Also - what other info are you looking for? If you attempt to enable test fixtures via AGP in a kotlin multiplatform project that has an android target, the resulting assembled gradle module.json does not contain test fixture metadata in it. An example project you could use (and where I noticed this) is github.com/slackhq/circuit, where we would like to have circuit-foundation expose a test fixture of the circuit-test artifact.
sp...@google.com <sp...@google.com> #38
Re: #32,
Thanks for the repro project! I see what's going on now.
You're using compose in your :core:analytics
modules but not in the testFixtures for that module, so you don't want the extra testFixturesImplementation(libs.androidx.compose.runtime)
dependency because there's no need for it.
The problem is that some users might want to use compose in their testFixtures, in which case they would actually need the the extra testFixturesImplementation(libs.androidx.compose.runtime)
dependency.
There's currently no way to enable compose for a module but not its testFixtures (or vice versa); the android.buildFeatures.compose
flag applies to all the components of a module. I've filed
sp...@google.com <sp...@google.com> #39
Re: #37,
Here or on youtrack? Also - what other info are you looking for? If you attempt to enable test fixtures via AGP in a kotlin multiplatform project that has an android target, the resulting assembled gradle module.json does not contain test fixture metadata in it. An example project you could use (and where I noticed this) is github.com/slackhq/circuit, where we would like to have circuit-foundation expose a test fixture of the circuit-test artifact.
Thanks for the extra info.
I think youtrack would be the right place to start the discussion about supporting Android testFixtures in a KMP project.
There is currently no support for testFixtures in our incubating "com.android.kotlin.multiplatform.library" plugin.
sp...@google.com <sp...@google.com> #40
Re: #31,
Hi, I've tried testFixtures, but got some IDEA error inside kotlin class (using Android Studio Koala | 2024.1.1):
Cannot inline bytecode built with JVM target 17 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
The toolchain is configured, so my jvmTarget is set properly. kotlin-stdlib also included in testFixtures sourceSet.
I opened the repro project from #32 in Android Studio, but I didn't see the error above. can you give repro steps?
The toolchain is configured
How are you configuring the toolchain?
To clarify, you don't see the error when building from the command line, right?
za...@gmail.com <za...@gmail.com> #41
Filed
d....@gmail.com <d....@gmail.com> #42
Re: #40,
Yeah, I've prepared the minimum reproduced sample below.
Build tasks is ok, but if you run dependencies
task - *Metadata is failed for some reason, maybe it helps.
sp...@google.com <sp...@google.com> #43
Re: #42,
Thanks for the repro project! I've created
li...@gmail.com <li...@gmail.com> #44
li...@gmail.com <li...@gmail.com> #45
I have another question about compose.runtime
dependency into the testFixtures
?
sp...@google.com <sp...@google.com> #46
Re #45, in general, AGP shouldn't be adding implicit dependencies.
lo...@gmail.com <lo...@gmail.com> #47
@
al...@gmail.com <al...@gmail.com> #48
_Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:_
* _Android Studio Meerkat | 2024.3.1 Canary 6_
* _Android Gradle Plugin 8.9.0-alpha06_
_We encourage you to try the latest update._
_If you notice further issues or have questions, please file a new bug report._
**_Thank you for taking the time to submit feedback — we really appreciate it!_**
al...@gmail.com <al...@gmail.com> #49
sp...@google.com <sp...@google.com> #51
AGP's Built-in Kotlin support is partially ready (with some notable compatibility issues with some other Gradle plugins).
While we're resolving those compatibility issues, we'd like to get some feedback from any of you willing to explore this feature in its current state.
AGP's Built-in Kotlin support allows module-by-module migration, so you can try migrating modules that don't use KSP or other currently incompatible plugins.
How to Enable Built-In Kotlin Support:
- Upgrade to AGP
8.10.0-alpha02
or later. - Apply the
"com.android.experimental.built-in-kotlin"
plugin to your module.- Ensure the plugin version matches the version of AGP being used.
- Note: Using this plugin will force the Kotlin Gradle Plugin (KGP) version to be at least
2.1.0
.
- Remove the
"org.jetbrains.kotlin.android"
plugin (a.k.a. the"kotlin-android"
plugin) from your module.
Breaking Changes:
- The deprecated
android.kotlinOptions
DSL is no longer supported. You must migrate to thekotlin.compilerOptions
DSL. - The
testApi
andandroidTestApi
configurations are no longer supported. - If you wrote a Gradle plugin that checks for an instance of
KotlinBasePluginWrapper
, you'll need to change it to check for an instance ofKotlinBasePlugin
instead. (AGP's Built-in Kotlin support internally appliesKotlinBaseApiPlugin
, which extendsKotlinBasePlugin
but notKotlinBasePluginWrapper
.)
Known Issues:
- The build fails if there are
"org.jetbrains.kotlin"
dependencies without specified versions. - Incompatibility with KSP (
https://github.com/google/ksp/issues/2093 ). - Incompatibility with some other Gradle plugins (Most Gradle plugins implementing
KotlinCompilerPluginSupportPlugin
will not work as expected).
We appreciate any feedback, including insights into compatibility, migration challenges, or suggestions for improvement. Thanks!
Description
Support Kotlin compilation directly in AGP. This allows dropping
kotlin-android
plugin andkapt
plugin for Android, and both of these are poking into some AGP internals and are hard to maintain in the long run.