我最近创建了我在我的Android项目进口的库Jar文件。我能够调用函数和使用类是present在这个Jar文件,而Android工作室不断告诉我,它无法解析符号我现在用的是类。请看下面的截图:
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 Studio keeps telling me that it cannot "resolve symbol" of the class I am using. Please see the screenshot below:
点击查看完整大小的图片
在code建立并执行成功。函数 isThisThingWorking()
只返回真
,而这正是布尔等等
被设置为
The code builds and executes successfully. The function isThisThingWorking()
simply returns true
, and that is just what boolean blah
gets set to.
我已经试过pressing的同步工程与摇篮文件
按钮并使用无效缓存/重新启动......
从Android的Studio的文件菜单,但没有解决这个问题。我能做些什么,使Android的Studio IDE中不显示无法解析符号xxxSDK
错误?
I have tried pressing the Sync Project with Gradle Files
button and using the Invalidate Caches / Restart...
option from Android Studio's File
menu, but none of this solved the issue. What can I do to make the Android Studio IDE not display the Cannot resolve symbol 'xxxSDK'
error?
我发现了问题 - 我的 SDK.jar
没有正确生成。它包括的.java
文件,而不是的.class
文件。这就解释了为什么在IDE无法查找SDK类。该封装结构仍处于罐,这就是为什么软件包的名称本身就不是一个红色正确的。在code工作正常,因为编译器知道编译的.java
文件。
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.
要解决这个问题,我修改了 build.gradle
我的SDK的项目,包括的.class
文件,而不是的.java
文件,创建JAR时。包括这个新的JAR,而不是旧罐固定在IDE的问题。
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.