Adding cn1 library to project in IntelliJ doesn't add it to classpath

58 views
Skip to first unread message

Philip Schaffner

unread,
Feb 16, 2021, 10:54:56 AM2/16/21
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: IntelliJ IDEA
Desktop OS: Windows 10

When I add the cn1lib "sensors" via the extensions-menu and click "Refresh cn1lib", something seems to be downloaded and compiling. However, when I try to import a class from the library, it doesn't seem to be in the classpath.
I tried all the things I could think of. The only one that seemed to do anthing was copying the class files into the lib folder manually. This creates a problem because then there are multiple Implementations of the SensorManager in the classpath and it won't build.
On Netbeans, the same code compiles and runs without issue.

Any idea what I'm doing wrong here?
Cheers
Philip

Shai Almog

unread,
Feb 16, 2021, 9:33:06 PM2/16/21
to CodenameOne Discussions
Hi,
this should work but there might be a regression in project creation in one of our recent plugin releases  (the latest should be fine).

After doing a Refresh cn1libs open the "Messages" section. Toggle off the Tree mode on the left hand side to see the actual printouts. There might be some errors related to proguard there. You can remove that entire section from the build.xml if it's there.

After the process of refresh is done you can expand "lib/impl/cls" where you should be able to see all the expanded classes you should be able to import. Are the files there?

Philip Schaffner

unread,
Feb 17, 2021, 1:45:22 AM2/17/21
to CodenameOne Discussions
Hi Shai

Thanks a lot for the response, much appreciated. The classes were not there in lib/impl/cls, but there was indeed an error related to build.xml in that the directory \build\tmp seemed to be not created (even though the message said so):
Running the IDE as administrator fixes the issue: the directory gets created, the classes are added to lib/impl/cls and compilation works as expected afterwards. I don't know if this is an issue specific to my setup, but I assume that it isn't, as I'm using the standard configuration and project path for IntelliJ.

Thank you very much! Kind regards
Philip

Shai Almog

unread,
Feb 17, 2021, 11:16:53 PM2/17/21
to CodenameOne Discussions
Hi Philip,
I'm not sure how it would happen that a directory under the project hierarchy isn't writable?
Do you have any idea how the project got to that state?

Philip Schaffner

unread,
Feb 22, 2021, 10:48:16 AM2/22/21
to CodenameOne Discussions
Hi Shai
Again thanks for your message and sorry for the slow reply, but I wanted to test it out first:
I experience this behaviour on every project I create with IntelliJ. I also did a fresh install of IntelliJ on a different machine and the same thing happens. I use IntelliJ 2020.3 and have my projects in the default location ("C:\Users\username\IdeaProjects"). No other folders seem to be write-protected and any other actions using IntelliJ work without issue (building, creating/deleting files etc). I was only able to reproduce the issue with the unwritable folder using "Refresh cn1lib" from the CodenameOne-Menu.

Kind regards
Philip

Shai Almog

unread,
Feb 22, 2021, 10:02:07 PM2/22/21
to CodenameOne Discussions
Hi,
we'll verify the fix again. Might need to release a new update this weekend to solve this. Thanks!
Reply all
Reply to author
Forward
0 new messages