Note that an error occurred while rewriting the test code written in Java while coexisting with kotlin.
The error message is below.
/Users/nakayama/StudioProjects/ChatMessageView/example/src/androidTest/java/com/github/bassaer/example/MessengerActivityTest.java:13:error:Package com.github.bassaer.example.matcher does not exist
import com.github.bassaer.example.matcher.MessageListMatcher;
^
/Users/nakayama/StudioProjects/ChatMessageView/example/src/androidTest/java/com/github/bassaer/example/MessengerActivityTest.java:146:error:Can't find symbol
onView(withId(R.id.message_view)).check(matches(MessageListMatcher.withListSize(0)));
If I wrote a process to call MessageListMatcher.kt under kotlin from MessagngerActivityTest.java under java, the build will pass, but when I execute it, the above error occurs.
├── androidTest
│ ├── java
│ │ └── com
│ │ └── github
│ │ └── bassaer
│ │ └── example
│ │ ├── MainActivityTest.java
│ │ ├── MessengerActivityTest.java
│ │ ├── matchers
│ │ │ ├── DrawableMatcher.java
│ │ │ ├── ImageViewDrawableMatcher.java
│ │ │ └── TextColorMatcher.java
│ │ └── util
│ │ └── ElapsedTimeIdlingResource.java
│ └── kotlin
│ └── com
│ └── github
│ └── bassaer
│ └── example
│ ├── matcher
│ │ ├── ColorMatcher.kt
│ │ └── MessageListMatcher.kt
│ └── util
└── main
I'm trying to read the kotlin folder with sourceSets, but I get an error.
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
I forgot to write this.
apply plugin: 'kotlin-android'
that's all.
Recommended Posts