Skip to content

Commit 7ee5eef

Browse files
committed
build(Gradle): fix Kotlin compilation errors in instrumentation tests
The "Unresolved reference" errors are for hidden symbols from the prebuilt AOSP's android.jar library, that is not visible anymore in the instrumentation tests when loaded via compileOnly API. Since Kotlin 1.8, it's required to explicitly use androidTestCompileOnly API to load a library for the instrumentation tests. See for more https://kotlinlang.org/docs/whatsnew18.html#kotlin-multiplatform-a-new-android-source-set-layout > Task :compileDebugAndroidTestKotlin FAILED e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/SimPinFeederComponentTest.kt:63:52 Unresolved reference: selectableSubscriptionInfoList e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/SimPinFeederComponentTest.kt:63:86 Not enough information to infer type variable T e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/SimPinFeederComponentTest.kt:67:28 Cannot infer a type for this parameter. Please specify it explicitly. e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/SimPinFeederComponentTest.kt:68:68 Unresolved reference: it e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/SimPinFeederComponentTest.kt:69:29 Cannot infer a type for this parameter. Please specify it explicitly. e: file:///mnt/storage/projects/7sim/7sim/tests/androidTest/src/java/com/github/iusmac/sevensim/telephony/TelephonyControllerComponentTest.kt:58:23 Unresolved reference: SimState Signed-off-by: iusmac <iusico.maxim@libero.it>
1 parent d23b644 commit 7ee5eef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ allprojects {
120120
}
121121

122122
ext {
123-
addCompileOnlyJar = { String name ->
123+
addCompileOnlyJar = { String name, boolean requiredByAndroidTest = false ->
124124
final def jars_dir = "$rootDir/prebuilts/jars"
125125
final def jar = new File(jars_dir, name)
126126
if (!jar.exists()) {
@@ -136,6 +136,9 @@ allprojects {
136136
}
137137
dependencies {
138138
compileOnly files(jar)
139+
if (requiredByAndroidTest) {
140+
androidTestCompileOnly files(jar)
141+
}
139142
}
140143
}
141144
}
@@ -290,7 +293,7 @@ android {
290293
}
291294
}
292295

293-
addCompileOnlyJar('android-35.jar')
296+
addCompileOnlyJar('android-35.jar', /*requiredByAndroidTest*/ true)
294297

295298
dependencies {
296299
implementation libs.annotation

0 commit comments

Comments
 (0)