Android Studio cannot resolve symbol but code executes correctly

前端 未结 9 2059
误落风尘
误落风尘 2020-11-27 04:06

I have recently created a library Jar file that I imported in my Android project. I am able to call functions and use classes that are present in this Jar file, but Android

9条回答
  •  再見小時候
    2020-11-27 04:55

    I found the issue - my SDK.jar was not generated correctly. It included .java files instead of .class files. This explains why the IDE was not able to find the SDK class. The package structure was still correct in the Jar, which is why the package name itself is not a red color. The code worked correctly, because the compiler knew to compile the .java files.

    To solve the issue, I modified my build.gradle of my SDK project to include .class files, instead of .java files, when creating the Jar. Including this new Jar instead of the old Jar fixed the IDE issue.

    EDIT: For most folks, Senthil's answer will be more appropriate. I am leaving this one as the accepted answer because it solved my specific problem.

提交回复
热议问题