我正在设置我的第一个仪器化单元测试,并在 logcat 中遇到了一个不起眼的崩溃。
模拟器启动并在应用程序尝试打开时立即崩溃,并且单元测试甚至没有运行,因为应用程序没有处于正确的状态。
2022-02-09 19:30:37.116 25764-25764/com.anotherday.day17.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.anotherday.day17.test, PID: 25764
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.anotherday.day17.test/androidx.activity.ComponentActivity}: java.lang.ClassNotFoundException: Didn't find class "androidx.activity.ComponentActivity" on path: DexPathList[[zip file "/data/app/~~NodQZs7v97-vYTPte3T7UQ==/com.anotherday.day17.test-25XuwB3vTwyNbSX-nlETDQ==/base.apk"],
它似乎正在寻找在以下 gradle 依赖项中定义的 androidx.activity.ComponentActivity:
implementation 'androidx.activity:activity-compose:1.3.1'
不知道在哪里看,这是我的第一个测试和我在 git 中的项目: https ://github.com/davida5/ComposeNotepad/blob/main/app/src/androidTest/java/com/anotherday/day17/navigation/NavigatorTest .kt