![](/img/trans.png)
[英]Unresolved reference: ext when importing androidx.test.ext.junit.rules.ActivityScenarioRule
[英]JUnit Local Test - 'Unresolved reference: test'
將androidx.test:core:1.2.0
, androidx.test.ext:truth:1.2.0
, com.google.truth:truth:0.44
等庫導入到名為ExampleUnitTest.kt的本地JUnit測試類中。
未解決的參考:測試
ExampleUnitTest.kt
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import com.google.common.truth.Truth.assertThat
這似乎是Android Testing Codelab示例應用程序中記錄的問題。
在Codelab示例build.gradle中,這被稱為已知問題。
// Once https://issuetracker.google.com/127986458 is fixed this can be testImplementation
implementation "androidx.test:core:$androidXTestCoreVersion"
我將應用的依賴關系重構為testImplementation
而不是androidTestImplementation
。
testImplementation 'androidx.test:core:1.2.0'
testImplementation 'androidx.test.ext:truth:1.2.0'
testImplementation 'com.google.truth:truth:0.44'
注意 -應更新Google文檔“ AndroidX測試的設置”項目以反映此問題,因為它目前指示開發人員使用androidTestImplementation
。 我已提交文檔問題以解決此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.