Android Studio 的编辑器抱怨它无法解析单元测试中的符号,尽管
main/
和 test/
中的目录结构匹配正确。
尽管如此,测试还是会通过...
我已经使缓存失效并重新启动,并在
~/.gradle
中清除了我的 Gradle 缓存,但我只希望前者会对编辑器窗口产生任何影响,因为 - 就像我说的 - 测试 does 通过.
这个问题只有在我删除文件夹结构中不需要的层时才会出现:
agent2/app/src
成为
agent2/src
并且没有对任何
app
文件夹的引用
(显然这是对真实项目的简化)
top-level-project
agent2/
src/
main/
com/
level1/
Class1.java
level2/
Class2.java
test/
com/
level1/
Class1Test.java
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName productVersionName
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
}
}
testOptions {
unitTests {
includeAndroidResources = true
unitTests.returnDefaultValues = true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-common:2.2.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.json:json:20190722'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
testImplementation 'org.powermock:powermock-core:2.0.7'
testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.7'
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
rootProject.name = "top-level-proj"
include "agent2"
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "com.jfrog.artifactory" version "4.24.14"
id "maven-publish"
}
apply from: 'publish.gradle'
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}