"Error: Package xxx does not exist" "Error: Symbol not found" when rewriting kotlin

Note that an error occurred while rewriting the test code written in Java while coexisting with kotlin.

Contents

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'
}

Conclusion

I forgot to write this.

apply plugin: 'kotlin-android'

that's all.

Recommended Posts

"Error: Package xxx does not exist" "Error: Symbol not found" when rewriting kotlin
Error in ./gradlew: Symbol not found
eclipse package org.springframework.boot.web.servlet.support does not exist
Symbol not found error when new class in another Java file
[Error] ActiveRecord :: NoDatabaseError FATAL: database does not exist
About error PG :: UndefinedTable: ERROR: relation "XXXXXX" does not exist
Handling when calling a key that does not exist in hash
Attempting pip install pytorch on jetson nano resulted in an error (error: package directory'torch / cuda' does not exist)
operator does not exist: handling the error timestamp without time zone ~~ unknown