[Android] Record a pitfall where a class can be referenced but an Unresolved reference error occurs during compilation

Android records that once a class can be referenced, but an Unresolved reference error occurs during compilation

Recently when I was developing, my project A referenced the module under the local project B. AndroidStudio showed normal references in project A, but it always reported an Unresolved reference error during compilation.

Insert image description here

But the strange thing is that project B was compiled successfully. I was puzzled. I accidentally saw this blog and gave me an idea.

But my situation is not nearly the same, which reminds me that it is actually compiled into aar and then called. Then I opened the aar of the project build to see if the class was really not generated. Sure enough, it was not.

Insert image description here

Solution

Suddenly it occurred to me that what I wrote was kotlin -> the kotlin plug-in was not added!!!

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
}

Insert image description here
perfect, nice

Guess you like

Origin blog.csdn.net/weixin_42473228/article/details/135189384