android / android/android-test
androidx.test:core-ktx doesn't work on a Java 6 project
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 342
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 2
Description
### Description
When using a project that uses Kotlin but uses Java 1.6 - my actual project is a library project that is not ready to force downstream apps to compile with Java 1.7+,
I cannot use ActivityScenario.launchActivity() since it appears the core-ktx module is compiled with Java 1.7 bytecode.
### Steps to Reproduce
1. Create a new project in Android Studio
2. Add a dependency on androidTestImplementation 'androidx.test:core-ktx:1.1.0' (or any later version)
3. Write a test that uses ActivityScenario.launchActivity:
```
@Test
fun withLaunchActivity() {
// This line fails to compile
with(launchActivity()) {
onActivity {
assertTrue(it.lifecycle == Lifecycle.State.RESUMED)
}
}
}
```
### Expected Results
core-ktx is usable on projects that compile against Java 1.6.
### Actual Results
Fails with an error:
> Cannot inline bytecode built with JVM target 1.7 into bytecode that is being built with with JVM target 1.6. Please specify proper '-jvm-target' option
### AndroidX Test and Android OS Versions
'androidx.test:core-ktx:1.1.0' (or any later version)
### Link to a public git repo demonstrating the problem:
https://github.com/ianhanniballake/TestCoreKtxIssue
Contributor guide
Research direction
Start by reproducing the Java 1.6/JVM target failure with the linked TestCoreKtxIssue repository and the androidx.test:core-ktx dependency. Inspect the core-ktx build configuration and bytecode target settings. Done means ActivityScenario.launchActivity can be used from a Java 1.6 project without the reported inline-bytecode error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- build-system, mobile, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100