我正在尝试在我的 Android 项目(使用 AndroidX)中运行标准的 ExampleInstrumentedTest,但得到“未找到测试”错误。我已经浏览了其他问题和文档,我很确定我已经做对了一切,但也许我忽略了什么?
这是我的应用程序的 build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.ext.junit.runners.AndroidJUnit4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Gradle automatically adds 'android.test.runner' as a dependency.
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
repositories {
mavenCentral()
maven {
url("https://oss.sonatype.org/content/repositories/snapshots")
}
maven { url 'https://jitpack.io' }
}
dependencies {
// Core library
androidTestImplementation 'androidx.test:core:1.0.0'
// …Run Code Online (Sandbox Code Playgroud) 升级到 androidx 和 SDK 28 后,我在构建项目时收到以下错误:
.../app/src/main/res/values/styles.xml:90:5-93:13:AAPT:错误:预期引用但得到(原始字符串)#000000。
value/styles.xml 的相关行:
<style name="menu_labels_style">
<item name="android:background">@drawable/fab_label_background</item>
<item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
fab_label_background 资源(以防万一)是:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_semi_transparent"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/>
<corners
android:radius="2dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)